제출 #555657

#제출 시각아이디문제언어결과실행 시간메모리
555657fuad27Aliens (IOI16_aliens)C++17
12 / 100
160 ms2260 KiB
#include "aliens.h" #include<bits/stdc++.h> using namespace std; const long long INF = 1e18; long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { for(int i = 0;i<n;i++) { if(c[i] < r[i]) { swap(c[i], r[i]); } } vector<pair<int,int>> pts; for(int i = 0;i<n;i++) { pts.push_back({c[i], r[i]}); } sort(pts.begin(), pts.end()); long long dp[n+1][k+1]; dp[0][0] = 0; for(int i = 1;i<=n;i++) { dp[i][0] = INF; } for(int i = 0;i<=k;i++)dp[0][i] = 0; for(int i = 1;i<=n;i++) { for(int j = 1;j<=k;j++) { int mx = 0; dp[i][j] = INF; for(int z = i;z>=1;z--) { mx = max(mx, pts[i-1].first-pts[z-1].second+1); dp[i][j] = min(dp[i][j], dp[z-1][j-1] + mx*mx); } } } return dp[n][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...