Submission #1022044

#TimeUsernameProblemLanguageResultExecution timeMemory
1022044vjudge1Aliens (IOI16_aliens)C++17
12 / 100
85 ms4388 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]; int R[maxn]; long long take_photos(int n, int m, int k, vector<int> r, vector<int> c){ for(int i=1;i<=m;i++){ L[i] = 1e9; } m = 0; for(int i=0;i<n;i++){ if(r[i] < c[i]){ swap(r[i], c[i]); } r[i]++, c[i]++; L[r[i]] = min(L[r[i]], c[i]); R[c[i]] = max(R[c[i]], r[i]); m = max(m, r[i]); } 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++){ R[i] = max(R[i], R[i-1]); for(int j=i-1;j>=0;j--){ if(L[j] > j && L[j+1] > j+1) continue; for(int t=1;t<=k;t++){ int l = R[j]; ll val = dp[l][t-1] + (i - j) * (i - j); if(l >= i) continue; if(l > j) val -= (l - j) * (l - j); dp[i][t] = min(dp[i][t], val); } } } return dp[m][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...