Submission #813463

#TimeUsernameProblemLanguageResultExecution timeMemory
813463MODDIAliens (IOI16_aliens)C++14
0 / 100
0 ms304 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; typedef pair<ll, ll> pll; typedef vector<ll> vl; int n, m, k; vector<int> row, col; long long take_photos(int N, int M, int K, std::vector<int> R, std::vector<int> C) { n = N; m = M; k = K; row = R; col = C; vector<pii> pts; for(int i = 0; i < n; i++) pts.pb({row[i], col[i]}); sort(pts.begin(), pts.end()); ll dp[n][k+1]; for(int i = 0; i < n; i++){ for(int j = 0; j <= k; j++){ dp[i][j] = 1e16; } } dp[0][0] = 0; dp[0][1] = 1; for(int i = 1; i < n; i++){ for(int pic = 1; pic <= k; pic++){ for(int j = i-1; j >= 0; j--){ dp[i][pic] = min(dp[i][pic], dp[j][pic-1] + (pts[i].second - pts[j+1].first + 1) * (pts[i].second - pts[j+1].first + 1)); } } } ll ans = 1e18; for(int pic = 0; pic <= k; pic++) ans = min(ans, dp[n-1][pic]); 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...