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;
const long long INF = 1e18;
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
for(int i = 0;i<n;i++) {
if(c[i] < r[i]) {
swap(c[i], r[i]);
}
}
map<int,int> mp;
vector<pair<int,int>> pts;
for(int i = 0;i<n;i++) {
pts.push_back({c[i], r[i]});
}
sort(pts.begin(), pts.end());
for(auto &i:pts) {
swap(i.second, i.first);
}
n = pts.size();
long long dp[n+1][k+1];
for(int i = 0;i<=k;i++)dp[0][i] = 0;
for(int j = 1;j<=n;j++)dp[j][0] = INF;
for(int i = 1;i<=n;i++) {
for(int j = 1;j<=k;j++) {
dp[i][j] = INF;
long long mx = (pts[i-1].second-pts[i-1].first+1);
for(int t = i;t>=1;t--) {
mx = max((long long)pts[i-1].second-pts[t-1].first+1, mx);
dp[i][j] = min(dp[i][j], dp[t-1][j-1]+mx*mx);
}
}
}
return dp[n][k];
}
# | 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... |