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>
#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... |