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 "aliens.h"
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define vll vector<ll>
#define ll long long
using namespace std;
const int tam=505;
int N;
ll dp[tam][tam];
vi v;
ll f(int pos, int k){
if(pos==N)return 0;
if(k==0)return 1e6;
if(dp[pos][k]!=-1)return dp[pos][k];
dp[pos][k]=1e16;
for(int i=pos;i<N;i++){
ll tam=v[i]-v[pos]+1;
dp[pos][k]=min(dp[pos][k],tam*tam+f(i+1,k-1));
}
return dp[pos][k];
}
void init(){
for(int i=0;i<tam;i++){
for(int l=0;l<tam;l++){
dp[i][l]=-1;
}
}
}
long long take_photos(int n, int m, int k,vi r,vi c){
sort(r.begin(),r.end());
N=n;
v=r;
init();
return f(0,min(k,n));
}
# | 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... |