Submission #1021989

#TimeUsernameProblemLanguageResultExecution timeMemory
1021989vjudge1Aliens (IOI16_aliens)C++17
0 / 100
1 ms2492 KiB
#include <bits/stdc++.h> #define ent '\n' typedef long long ll; using namespace std; const int maxn = 1e5+12; ll dp[1005][505]; int l[maxn]; long long take_photos(int n, int m, int k, vector<int> r, vector<int> c){ int mx = 0; for(int i=1;i<=m;i++){ l[i] = i+1; } for(int i=0;i<n;i++){ if(r[i] < c[i]){ swap(r[i], c[i]); } l[r[i]+1] = min(l[r[i]+1], c[i]+1); mx = max(mx, r[i] + 1); } for(int i=1;i<=m;i++){ for(int j=0;j<=k;j++){ dp[i][j] = 1e12; } } for(int i=1;i<=m;i++){ int mn = i; for(int j=i;j>=1;j--){ mn = min(mn, l[j]); for(int t=1;t<=k;t++){ ll val = dp[j-1][t-1] + (i - mn + 1) * 1ll * (i - mn + 1); if(mn <= j-1) val -= (j - mn) * 1ll * (j - mn); dp[i][t] = min(dp[i][t], val); } } } return dp[mx][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...