이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "aliens.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
ll dp[1005][1005], mn[1000005];
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
swap(n, m);
for(int i=0;i<n;i++)mn[i] = 1e18;
for(int i=0;i<m;i++){
ll x = max(r[i], c[i]), y = min(r[i], c[i]);
mn[x] = min(mn[x], y);
}
for(ll i=0;i<n;i++){
if(mn[i] == 1e18){
if(i)for(int j=0;j<=k;j++)dp[i][j] = dp[i-1][j];
continue;
}
ll lol = mn[i];
dp[i][0] = 1e18;
for(int j=1;j<=k;j++){
dp[i][j] = 1e18;
lol = mn[i];
for(int x=i-1;x>=0;x--){
lol = min(lol, (ll)x + 1);
if(lol > mn[x]){
dp[i][j] = min(dp[i][j], dp[x][j-1] + (i - lol + 1) * (i - lol + 1) - (x - lol + 1) * (x - lol + 1));
lol = mn[x];
}
else dp[i][j] = min(dp[i][j], dp[x][j-1] + (i - lol + 1) * (i - lol + 1));
}
dp[i][j] = min(dp[i][j], (i - lol + 1) * (i - lol + 1));
}
}
ll ans = 1e18;
for(int pics = 0; pics <= k; pics++)
ans = min(ans, dp[n-1][pics]);
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... |