이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 = 1e8;
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);
}
# | 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... |