This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "aliens.h"
//#include "grader.cpp"
using namespace std;
typedef long long ll;
const int MX=509;
int dp[MX][MX],a[MX],n,k;
int DP(int x,int y){
if(y>k)return MX*MX*MX;
if(x==n)return 0;
int &ret=dp[x][y];if(ret!=-1)return ret;
ret=MX*MX*MX;
for(int i=x;i<n;i++){
ret=min(ret,DP(i+1,y+1) + (a[i]-a[x]+1)*(a[i]-a[x]+1));
}
return ret;
}
ll take_photos(int N, int m, int K, vector<int> r, vector<int> c) {
n=N;k=K;
for(int i=0;i<n;i++)a[i]=r[i];
sort(a,a+n);
memset(dp,-1,sizeof(dp));
return DP(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... |