이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "aliens.h"
using namespace std;
const int N = 4010 , K = 4010;
vector< pair<int,int> > arr;
long long dp[N][K];
int n , m , k;
long long solve(int i,int cur){
if(i == n)
return 0;
if(cur == k)
return (long long)1e18;
if(dp[i][cur] != -1)
return dp[i][cur];
dp[i][cur] = (long long)1e18;
int mx = -1;
for(int j = i ;j < n;j++){
mx = max(mx,arr[j].second);
dp[i][cur] = min(dp[i][cur] , (long long)(mx - arr[i].first + 1) * (long long)(mx - arr[i].first + 1) + solve(j + 1, cur + 1));
}
return dp[i][cur];
}
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c){
::n = n;
::m = m;
::k = k;
for(int i = 0 ;i < n;i++){
arr.push_back(make_pair(min(r[i] , c[i]) , max(r[i] , c[i])));
}
sort(arr.begin(),arr.end());
memset(dp,-1,sizeof(dp));
return solve(0 , 0);
}
# | 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... |