이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#ifndef ARTHUR_LOCAL
#include "aliens.h"
#endif
using namespace std;
using ll = long long;
const int MAXN = 501;
ll dp[MAXN][MAXN];
ll take_photos(int n, int m, int k_in_question, vector<int> R, vector<int> C)
{
for(int i=0; i<MAXN; i++)
{
for(int j=0; j<MAXN; j++)
{
dp[i][j]=1e18;
}
}
dp[0][0]=0;
for(int i=0; i<n; i++) R[i]=R[i]+1;
R.push_back(0);
sort(R.begin(),R.end());
for(int i=1; i<=n; i++) // covering the first i things
{
for(int j=1; j<=i; j++) // with j intervals
{
for(int k=i; k>=1; k--) // the last thing considered was k (so k--i square)
{
dp[i][j] = min(dp[i][j], ll(R[i]-R[k]+1)*ll(R[i]-R[k]+1) + dp[k-1][j-1]);
}
// cout << i << " " << j << " " << dp[i][j] << endl;
}
}
ll ans = 1e18;
for(int j=1; j<=k_in_question; j++)
{
ans = min(ans,dp[n][j]);
}
return ans;
}
#ifdef ARTHUR_LOCAL
int main()
{
vector<int> V = {1,2};
cout << take_photos(2,10,1,V,V) << endl;
}
#endif
# | 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... |