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"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%I64d",&x)
#define SF2(x,y) scanf("%I64d%I64d",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()
using namespace std;
const long long INF = 1e15;
const int MX=200015;
int n,m,k;
int dp[505][505];
int a[505];
int DP(int x,int y){
if(x==n)R 0;
if(y==k)R INF;
int &ret=dp[x][y];
if(ret!=-1)R ret;
ret=INF;
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));
}
R ret;
}
long long take_photos(int n_, int m_, int k_, vector<int> r, vector<int> c) {
MEM(dp,-1);
n=n_,m=m_,k=k_;
for(int i=0;i<n;i++){
a[i]=r[i];
}
sort(a,a+n);
return DP(0,0);
}
Compilation message (stderr)
aliens.cpp: In function 'int DP(int, int)':
aliens.cpp:30:15: warning: overflow in implicit constant conversion [-Woverflow]
if(y==k)R INF;
^
aliens.cpp:33:8: warning: overflow in implicit constant conversion [-Woverflow]
ret=INF;
^
# | 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... |