제출 #30503

#제출 시각아이디문제언어결과실행 시간메모리
30503zoomswkAliens (IOI16_aliens)C++14
12 / 100
233 ms4796 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; vector<pair<int, int>> p; int L[100005], R[100005]; long long dp[505][505]; 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++) p.push_back({min(r[i], c[i]), -max(r[i], c[i])}); sort(p.begin(), p.end()); int N=1, tmp_mx=-1; for(int i=0; i<n; i++){ if(-p[i].second > tmp_mx){ L[N] = p[i].first, R[N] = -p[i].second; tmp_mx = -p[i].second; N++; } } N--; for(int i=1; i<=N; i++){ dp[i][0] = 1e18; for(int j=1; j<=k; j++){ dp[i][j] = 1e18; for(int x=1; x<=i; x++){ dp[i][j] = min(dp[i][j], dp[x-1][j-1]+1LL*(R[i]-L[x]+1)*(R[i]-L[x]+1)-(R[x-1] > L[x] ? 1LL*(R[x-1]-L[x]+1)*(R[x-1]-L[x]+1): 0LL)); } } } 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...