이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include "aliens.h"
using namespace std;
typedef long long int ll;
int N,M,K;
ll DP[1005][1005];
ll R[1005];
bool B[105][105];
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
N=n;
M=m;
K=k;
if(N==K and N<=50){
ll ans=0;
for(int i=0;i<N;i++)
for(int a=min(r[i],c[i]);a<=max(r[i],c[i]);a++)
for(int b=min(r[i],c[i]);b<=max(r[i],c[i]);b++)
B[a][b]=true;
for(int a=0;a<M;a++)
for(int b=0;b<M;b++)
if(B[a][b])
ans++;
return ans;
}
sort(r.begin(),r.end());
for(int i=0;i<N;i++)
R[i+1]=r[i];
for(int i=0;i<=N;i++)
for(int k=0;k<=K;k++)
DP[i][k]=1e18;
DP[0][0]=0;
for(int i=1;i<=N;i++)
for(int k=1;k<=K;k++){
DP[i][k]=DP[i][k-1];
for(int j=0;j<i;j++)
DP[i][k]=min(DP[i][k],DP[j][k-1]+(R[i]-R[j+1]+1)*(R[i]-R[j+1]+1));
}
//for(int i=1;i<=N;i++)for(int k=1;k<=K;k++)cout<<i<<" "<<k<<" "<<DP[i][k]<<endl;
return DP[N][K];
}
/*
2 7 2
1 1
3 3
*/
# | 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... |