# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1021988 | vjudge1 | Aliens (IOI16_aliens) | C++17 | 1 ms | 2396 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>
#define ent '\n'
typedef long long ll;
using namespace std;
const int maxn = 1e5+12;
ll dp[1005][505];
int l[maxn];
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c){
for(int i=1;i<=m;i++){
l[i] = i+1;
}
for(int i=0;i<n;i++){
if(r[i] < c[i]){
swap(r[i], c[i]);
}
l[r[i]+1] = min(l[r[i]+1], c[i]+1);
}
for(int i=1;i<=m;i++){
for(int j=0;j<=k;j++){
dp[i][j] = 1e12;
}
}
for(int i=1;i<=m;i++){
if(l[i] > i){
continue;
}
int mn = 1e9;
for(int j=i;j>=1;j--){
mn = min(mn, l[j]);
for(int t=1;t<=k;t++){
ll val = dp[j-1][t-1] + (i - mn + 1) * 1ll * (i - mn + 1);
if(mn <= j-1) val -= (j - mn) * 1ll * (j - mn);
dp[i][t] = min(dp[i][t], val);
}
}
}
for(int i=m;i>=0;i--){
if(dp[i][k] < 1e12){
return dp[i][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... |