제출 #958041

#제출 시각아이디문제언어결과실행 시간메모리
958041LalicAliens (IOI16_aliens)C++17
12 / 100
62 ms2648 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define mp make_pair typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5+10; const int MOD = 1e9+7; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; ll take_photos(int n, int m, int k, vector<int> r, vector<int> c) { vector<pll> interv; for(int i=0;i<n;i++) interv.pb({r[i], c[i]}); for(int i=0;i<n;i++) if(interv[i].fi>interv[i].se) swap(interv[i].fi, interv[i].se); sort(all(interv), [&](pll a, pll b){ return (a.fi!=b.fi ? a.fi<b.fi : a.se>b.se); }); int last=-1; vector<pll> proc; proc.pb({0, 0}); for(auto u : interv){ if(u.se<=last) continue; proc.pb(u); last=u.se; } n=(int)proc.size()-1; ll dp[505][505]; for(int i=0;i<=n;i++) for(int j=0;j<=k;j++) dp[i][j]=LINF; dp[0][0]=0; for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++){ for(int w=0;w<i;w++){ if(dp[w][j-1]==LINF) continue; dp[i][j]=min(dp[i][j], dp[w][j-1]+(proc[i].se-proc[w+1].fi+1ll)*(proc[i].se-proc[w+1].fi+1ll)); } } } ll best=LINF; for(int i=0;i<=k;i++) best=min(best, dp[n][i]); return best; }
#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...