제출 #158066

#제출 시각아이디문제언어결과실행 시간메모리
158066johuthaAliens (IOI16_aliens)C++14
0 / 100
2 ms376 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++) { for (int q = 0; q < i; q++) { int ol = 0; if (q > 0 && nl[q] <= nr[q - 1]) { ol = nr[q - 1] - nl[q]; ol *= ol; } dp[i][j] = min(dp[i][j], dp[q][k - 1] + (nr[i - 1] - nl[i - 1] + 1)*(nr[i - 1] - nl[i - 1] + 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...