이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n,m,k;
int dp[505][505]; //n,k
vector<pii> v;
long long take_photos(int N, int M, int K, vector<int> y, vector<int> x) {
n=N; m=M; k=K;
for (int i=0; i<n; ++i) v.push_back(pii(x[i],y[i]));
sort(v.begin(),v.end());
for (int i=0; i<n; ++i) for (int j=0; j<=k; ++j) dp[i][j]=1e9;
for (int j=1; j<=k; ++j) dp[0][j]=1;
for (int i=1; i<n; ++i) {
for (int j=1; j<=k; ++j) {
//find dp[i][j]
if (j==1) {
dp[i][j]=min(dp[i][j],(v[i].first-v[0].first+1)*(v[i].first-v[0].first+1));
} else {
for (int x=1; x<=i; ++x) { //capture i to x
dp[i][j]=min(dp[i][j],dp[x-1][j-1]+(v[i].first-v[x].first+1)*(v[i].first-v[x].first+1));
}
}
}
}
return dp[n-1][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... |