이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "aliens.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
const int MAX_N = 1e5 + 5;
const ll infinity = 1e18;
ll dp[MAX_N];
int ind[MAX_N];
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 (r[i] > c[i]) swap(r[i], c[i]);
}
iota(ind, ind + n, 0);
sort(ind, ind + n, [&] (int i, int j) {
return r[i] + c[i] < r[j] + c[j];
});
for (int i = 0; i < n; i++) {
dp[i] = infinity;
int left = m, right = 0;
for (int j = i; j >= 0; j--) {
chkmin(left, r[ind[j]]);
chkmax(right, c[ind[j]] + 1);
chkmin(dp[i], (j ? dp[j - 1] : 0) + ll(right - left) * (right - left));
}
}
return dp[n - 1];
}
# | 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... |