이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
int v[MX];
bool vis[MX][MX];
void add(int x,int y){
for(int i=x;i<=y;i++)for(int j=x;j<=y;j++)vis[i][j]=1;
}
ll take_photos(int N, int m, int K, vector<int> r, vector<int> c) {
n=N;k=K;
if(K == N){
for(int i=0;i<m;i++)v[i]=-1;
for(int i=0;i<n;i++){
if(r[i] > c[i])swap(r[i],c[i]);
int mn=min(r[i],c[i]);
int mx=max(r[i],c[i]);
add(mn,mx);
}
int ans=0;
for(int i=0;i<m;i++)for(int j=0;j<m;j++)ans+=vis[i][j];
return ans;
}
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... |