이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
int ZZZ=0;
if(i+1<N){
if(lolz[i].first==lolz[i+1].first)
ZZZ=1;
}
miner=min(miner,REC(i+1,left-1)+maxer*maxer-ZZZ);
}
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |