Submission #415073

#TimeUsernameProblemLanguageResultExecution timeMemory
415073Ahmadsm2005Aliens (IOI16_aliens)C++14
12 / 100
143 ms8196 KiB
#include "aliens.h" //#include "grader.cpp" #include<bits/stdc++.h> using namespace std; long long DP[1001][1001],N,M; vector<pair<long long,long long>>lolz; long long REC(int idx,int left){ if(idx>=N) return 0; else if(!left) return(long long)2e18; if(DP[idx][left]+1) return DP[idx][left]; long long miner=(long long)2e18,maxer=0; for(int i=idx;i<N;i++){ maxer=max(maxer,(lolz[i].second+1)-lolz[idx].first); miner=min(miner,REC(i+1,left-1)+maxer*maxer); } return DP[idx][left]=miner; } long long take_photos(int n,int m,int k,vector<int>r,vector<int>c){ M=m; N=n; for(int i=0;i<=1000;i++) for(int l=0;l<=1000;l++) DP[i][l]=-1; for(int i=0;i<n;i++){ lolz.push_back({min(r[i],c[i]),max(r[i],c[i])}); } sort(lolz.begin(),lolz.end()); return REC(0,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...