Submission #619800

#TimeUsernameProblemLanguageResultExecution timeMemory
619800A_DAliens (IOI16_aliens)C++14
12 / 100
157 ms2320 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; const int N=5e2+11; long long dp[N][N]; pair<long long,long long> a[N]; long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) { for(int j=1;j<=n;j++){ dp[0][j]=1e18; dp[j][0]=1e18; } for(int i=0;i<n;i++){ if(r[i]<c[i])swap(r[i],c[i]); a[i+1]={r[i],c[i]}; } sort(a+1,a+n+1); for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++){ long long ret=1e18; long long mn=a[i].second; long long mx=a[i].first; for(int h=i;h>=1;h--){ mn=min(mn,a[h].second); mx=max(mx,a[h].first); if(dp[h-1][j-1]==1e18)continue; long long u=(mx-mn+1)*(mx-mn+1)+dp[h-1][j-1]; ret=min(ret,u); } dp[i][j]=ret; } } // cout<<dp[0][0]<<" "<<dp[1][1]<<"\n"; long long ret=1e18; for(int i=1;i<=k;i++){ ret=min(ret,dp[n][i]); } return ret; }
#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...