Submission #158071

#TimeUsernameProblemLanguageResultExecution timeMemory
158071johuthaAliens (IOI16_aliens)C++14
25 / 100
253 ms2408 KiB
#include "aliens.h" #include <vector> #include <iostream> #include <deque> #include <algorithm> #define int long long using namespace std; int take_photos(signed n, signed m, signed k, vector<signed> r, vector<signed> c) { vector<pair<int,int>> intervals; for (int i = 0; i < n; i++) { intervals.push_back({min(r[i], c[i]), -max(r[i], c[i])}); } sort(intervals.begin(), intervals.end()); vector<int> nl; vector<int> nr; int mmx = -1; for (int i = 0; i < n; i++) { if (-intervals[i].second > mmx) { nl.push_back(intervals[i].first); nr.push_back(-intervals[i].second); mmx = -intervals[i].second; } } int nn = nl.size(); vector<vector<int>> dp(nn + 1, vector<int>(k + 1, 1e9)); dp[0][0] = 0; for (int i = 1; i <= nn; i++) { for (int j = 1; j <= k; j++) { dp[i][j] = min(dp[i][j], dp[i][j - 1]); for (int q = 0; q < i; q++) { int ol = 0; if (q > 0 && nl[q] <= nr[q - 1]) { ol = nr[q - 1] - nl[q] + 1; ol *= ol; } dp[i][j] = min(dp[i][j], dp[q][j - 1] + (nr[i - 1] - nl[q] + 1)*(nr[i - 1] - nl[q] + 1) - ol); } } } return dp[nn][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...