Submission #836997

#TimeUsernameProblemLanguageResultExecution timeMemory
836997erdemkirazAliens (IOI16_aliens)C++17
0 / 100
1 ms316 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int M = 1e6 + 5; int n, m, k; int at[M]; vector<ii> v; vector<vector<ll>> dp; ll f(int x, int k) { if(x > m + 2) { return 0; } ll &r = dp[x][k]; if(r != -1) { return r; } r = 1e18; if(!at[x]) { r = min(r, f(x + 1, k)); } if(k) { int mx = at[x]; for(int y = x + 1; y <= m + 2; y++) { mx = max(mx, at[y]); ll len = mx - x; r = min(r, f(y, k - 1) + len * len); } } return r; } ll take_photos(int nn, int mm, int kk, vector<int> r, vector<int> c) { n = nn; m = mm; k = kk; for(int i = 0; i < n; i++) { if(r[i] > c[i]) { swap(r[i], c[i]); } at[r[i] + 1] = max(at[r[i] + 1], c[i] + 2); } sort(v.begin(), v.end()); dp.resize(m + 3, vector<ll>(k + 1, -1)); ll ans = f(1, k); return ans; }
#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...