제출 #389065

#제출 시각아이디문제언어결과실행 시간메모리
389065alishahali1382Aliens (IOI16_aliens)C++14
25 / 100
91 ms6348 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define debug(x) {cerr<<#x<<"="<<x<<"\n";} #define debug2(x, y) {cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<"\n";} #define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";} #define pb push_back #define all(x) x.begin(), x.end() const int inf=1000001000; const int MAXN=100010, K=103; int n, m, k; pii A[MAXN]; ll dp[505][505]; inline ll _sq(ll x){ return x*x;} ll take_photos(int _n, int _m, int _k, vector<int> r, vector<int> c) { k=_k; m=_m; vector<pii> vec; for (int i=0; i<_n; i++) vec.pb({min(r[i], c[i]), max(r[i], c[i])}); sort(all(vec), [](pii i, pii j){ if (i.second!=j.second) return i.second<j.second; return i.first>j.first; }); for (pii p:vec){ while (n && p.first<=A[n].first) n--; A[++n]=p; } // for (int i=1; i<=n; i++) debugp(A[i]) k=min(k, n); memset(dp, 63, sizeof(dp)); for (int i=0; i<=k; i++) dp[0][i]=0; for (int i=1; i<=n; i++){ for (int j=1; j<=i; j++){ ll cost=_sq(A[i].second-A[j].first+1); if (j!=1 && A[j].first<=A[j-1].second) cost-=_sq(A[j-1].second-A[j].first+1); // cerr<<i<<" "<<j<<" "<<cost<<"\n"; for (int t=1; t<=k; t++) dp[i][t]=min(dp[i][t], dp[j-1][t-1]+cost); } } 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...