Submission #962963

#TimeUsernameProblemLanguageResultExecution timeMemory
962963penguin133Aliens (IOI16_aliens)C++17
25 / 100
124 ms22876 KiB
#include <bits/stdc++.h> using namespace std; #include "aliens.h" //#define int long long typedef long long ll; #define pi pair<ll, ll> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll dp[505][505], mn[1000005]; pi stuf[1000005]; long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { for(int i = 0; i <= m; i++)mn[i] = 1e18; for(int i = 0; i < n; i++){ if(r[i] > c[i])swap(r[i], c[i]); mn[c[i]] = min(mn[c[i]], (ll)r[i]); stuf[i] = {c[i], r[i]}; } sort(stuf, stuf + n); for(int i = m - 1; i >= 0; i--)mn[i] = min(mn[i], mn[i + 1]); //return 0; for(int i = 0; i <= n; i++)dp[i][0] = 1e18; for(int i = 0; i < n; i++){ for(int j = 1; j <= k; j++){ dp[i][j] = 1e18; for(int a = i; a >= 0; a--){ dp[i][j] = min(dp[i][j], (a ? dp[a - 1][j - 1] : 0) + (stuf[i].fi - mn[stuf[a].fi] + 1) * (stuf[i].fi - mn[stuf[a].fi] + 1) - (a ? max(0ll, stuf[a - 1].fi - mn[stuf[a].fi] + 1) * (stuf[a - 1].fi - mn[stuf[a].fi] + 1) : 0) ); } } } return dp[n - 1][k]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...