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++)
{
for(int j=1; j<=i; j++)
{
for(int k=i; k>=1; k--)
{
dp[i][j] = min(dp[i][j], ll(R[i]-R[k]+1)*ll(R[i]-R[k]+1) + dp[k-1][j-1]);
}
}
}
ll ans = 1e18;
for(int j=1; j<=k_in_question; j++)
{
ans = min(ans,dp[n][k_in_question]);
}
return ans;
}
# | 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... |