이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "aliens.h"
//#define int long long
typedef long long ll;
#define pi pair<ll, ll>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll dp[505][505], mn[1000005];
pi stuf[1000005];
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
for(int i = 0; i <= m; i++)mn[i] = 1e18;
for(int i = 0; i < n; i++){
if(r[i] > c[i])swap(r[i], c[i]);
mn[c[i]] = min(mn[c[i]], (ll)r[i]);
stuf[i] = {c[i], r[i]};
}
sort(stuf, stuf + n);
for(int i = m - 1; i >= 0; i--)mn[i] = min(mn[i], mn[i + 1]);
//return 0;
for(int i = 0; i <= n; i++)dp[i][0] = 1e18;
for(int i = 0; i < n; i++){
for(int j = 1; j <= k; j++){
dp[i][j] = 1e18;
for(int a = i; a >= 0; a--){
dp[i][j] = min(dp[i][j], (a ? dp[a - 1][j - 1] : 0) + (stuf[i].fi - mn[stuf[a].fi] + 1) * (stuf[i].fi - mn[stuf[a].fi] + 1) - (a ? (stuf[a - 1].fi - mn[stuf[a].fi] + 1) * (stuf[a - 1].fi - mn[stuf[a].fi] + 1) : 0) );
}
}
}
return dp[n - 1][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... |