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, vector<int> r, vector<int> c) {
r.erase(unique(r.begin(), r.end()), r.end());
n = r.size();
vector<vector<long long>> dp(k, vector<long long> (n, INF));
for (int i = 0; i < n; i++) dp[0][i] = (long long) (r[i] - r[0] + 1) * (r[i] - r[0] + 1);
for (int j = 1; j < k; j++)
for (int i = j; i < n; i++)
for (int k = 0; k < i; k++)
dp[j][i] = min(dp[j][i], dp[j - 1][k] + (long long) (r[i] - r[k + 1] + 1) * (r[i] - r[k + 1] + 1));
long long ans = INF;
for (int i = 0; i < k; i++) ans = min(ans, dp[i][n - 1]);
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... |