#include "aliens.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define ALL(x) (x.begin()), (x.end())
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DEBUG_ARR(x) cerr << #x << ": "; for (auto &y : x) cout << y << " "; cout << endl;
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
ll ans = 0;
sort(ALL(r));
vi a = {r[0]};
for (int x : r) if (x != a.back()) a.push_back(x);
n = SZ(a);
vvl dp(n+1, vl(k+1, 1e18));
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= i; j++) {
for (int p = 0; p < k; p++) {
ll d = a[i]-a[j]+1;
dp[i+1][p+1] = min(dp[i+1][p+1], dp[j][p]+d*d);
}
}
}
return *min_element(ALL(dp[n]));
}
Compilation message (stderr)
aliens.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
aliens_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |