Submission #997174

#TimeUsernameProblemLanguageResultExecution timeMemory
997174VMaksimoski008Aliens (IOI16_aliens)C++17
12 / 100
121 ms2396 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; ll take_photos(int n, int m, int k, vector<int> r, vector<int> c) { //subtask 2 gl hf vector<pii> P; P.push_back({ -1, -1 }); for(int i=0; i<n; i++) { if(r[i] > c[i]) P.push_back({ c[i], r[i] }); else P.push_back({ r[i], c[i] }); } sort(P.begin(), P.end()); ll dp[n+1][k+1]; for(int i=0; i<=n; i++) for(int j=0; j<=k; j++) dp[i][j] = 1e9; dp[0][0] = 0; for(int i=1; i<=n; i++) { for(int j=1; j<=k; j++) { int mn = 1e9, mx = 0; for(int x=i; x>=1; x--) { mn = min(mn, P[x].first); mx = max(mx, P[x].second); dp[i][j] = min(dp[i][j], dp[x-1][j-1] + (mx - mn + 1) * (mx - mn + 1)); } } } return *min_element(dp[n], dp[n]+k+1); }
#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...