# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124848 | nvmdava | Aliens (IOI16_aliens) | C++17 | 100 ms | 2428 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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) {
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];
}
Compilation message (stderr)
# | 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... |