# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
124847 | nvmdava | Aliens (IOI16_aliens) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v, t;
long long dp[505][505];
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
memset(temp, -1, sizeof temp);
for(int i = 0; i < n; i++)
t.push_back({min(r[i], c[i]), max(c[i], r[i]) + 1});
sort(t.begin(), t.end());
int mx = -1;
v.push_back({-1, -1});
for(auto& x : t)
if(x.second > mx)
v.push_back({x.first, mx = x.second});
n = v.size() - 1;
k = min(k, n);
memset(dp, 0x3f3f, sizeof dp);
dp[0][0] = 0;
for(int i = 1; i <= k; i++){
for(int j = 1; j <= n; j++){
dp[i][j] = dp[i - 1][j];
for(int l = 0; l < j; l++){
dp[i][j] = min(dp[i][j], dp[i - 1][l] + (v[j].second - v[l + 1].first) * (v[j].second - v[l + 1].first));
}
}
}
return dp[k][n];
}