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 "aliens.h"
#include <bits/stdc++.h>
using namespace std;
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c){
set<int> st;
for (int i = 0; i < n; ++i)
{
st.insert(r[i]);
}
if(k>=n) return st.size();
vector<int> tab;
tab.push_back(-1);
for(auto u:st) tab.push_back(u);
int dp[n+1][k+1];
for (int i = 0; i <= n; ++i)
{
for (int j = 0; j <= k; ++j)
{
dp[i][j]=1e9;
}
}
int ans=m*m;
dp[0][0]=0;
for (int i = 1; i <= n; ++i)
{
int lst=tab[i];
int cur=1;
for (int j = i; j > 0 ; --j)
{
cur+=lst-tab[j];
lst=tab[j];
//cout <<i<<" "<<j<<" "<<cur<<" "<<dp[j-1][1]<<endl;
for (int t = 1; t <= k; ++t)
{
dp[i][t]=min(dp[i][t],dp[j-1][t-1]+cur*cur);
}
}
}
for (int i = 0; i <= k; ++i)
{
ans=min(ans,dp[n][k]);
}
return ans;
}
/*int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout <<"aaa"<<endl;
int n, m, k;
assert(3 == scanf("%d %d %d", &n, &m, &k));
std::vector<int> r(n), c(n);
for (int i = 0; i < n; i++) {
assert(2 == scanf("%d %d", &r[i], &c[i]));
}
long long ans = take_photos(n, m, k, r, c);
printf("%lld\n", ans);
return 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... |