# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
344452 | Sparky_09 | Aliens (IOI16_aliens) | C++17 | 1 ms | 384 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 "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define ll long long
//typedef long long int;
typedef pair<int, int> pii;
typedef vector<int> vi;
#include "aliens.h"
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
ll dp[n+10][n+10];
memset(dp, 0x3f, sizeof dp);
/*
dp[ind][k] = min(dp[int-1][k-1]) + area
*/
vector<pair<ll, ll>> vpi;
for(int i = 0; i < n; i++) vpi.emplace_back(c[i], r[i]);
sort(vpi.begin(), vpi.end());
//dp[0][1] = 1;
for(int i = 0; i < n; i++) dp[i][1] = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j <= i; j++){ // previous one
for(int l = 1; l <= k; l++){
ll curr, curc, prevr, prevc;
curc = vpi[i].first; curr = vpi[i].second;
prevc = vpi[j].first; prevr = vpi[j].second;
ll area = (curc - prevc + 1) * (curc - prevc + 1);
if(j==0) dp[i][l] = min(dp[i][l], min(dp[i][l-1], area));
else dp[i][l] = min(dp[i][l-1], min(dp[i][l-1], dp[j-1][l-1] + area));
}
}
}
if(dp[n-1][k]==2) dp[n-1][k]=1;
return dp[n-1][k];
}
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... |