이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
int n, m, k;
vector<int> row, col;
long long take_photos(int N, int M, int K, std::vector<int> R, std::vector<int> C) {
n = N;
m = M;
k = K;
row = R;
col = C;
vector<pii> pts;
for(int i = 0; i < n; i++)
pts.pb({row[i], col[i]});
sort(pts.begin(), pts.end());
ll dp[n][k+1];
for(int i = 0; i < n; i++){
for(int j = 0; j <= k; j++){
dp[i][j] = 1e16;
}
}
dp[0][0] = 0;
dp[0][1] = 1;
for(int i = 1; i < n; i++){
for(int pic = 1; pic <= k; pic++){
for(int j = i-1; j >= 0; j--){
dp[i][pic] = min(dp[i][pic], dp[j][pic-1] + (pts[i].second - pts[j+1].first + 1) * (pts[i].second - pts[j+1].first + 1));
}
}
}
ll ans = 1e18;
for(int pic = 0; pic <= k; pic++)
ans = min(ans, dp[n-1][pic]);
return ans;
}
# | 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... |