# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
961723 | Ahmed57 | Aliens (IOI16_aliens) | C++17 | 1 ms | 376 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>
#include "aliens.h"
using namespace std;
long long take_photos(int n, int m, int k, vector<int> r,vector<int> c){
vector<pair<long long,long long>> seg1,seg;
for(int i = 0;i<n;i++){
seg1.push_back({min(c[i],r[i]),max(c[i],r[i])});
}
long long ma = -1e18;
for(int i = 0;i<n;i++){
if(seg1[i].second>ma){
seg.push_back(seg1[i]);
ma = seg1[i].second;
}
}
long long dp[seg.size()+1][k+1];
for(int i = 0;i<=k;i++)dp[0][i] = 0;
for(int i = 1;i<=seg.size();i++){
dp[i][0] = 1e18;
for(int j = 1;j<=k;j++){
dp[i][j] = 1e18;
for(int e = 0;e<i;e++){
dp[i][j] = min(dp[i][j],dp[e][j-1]+(seg[i-1].second-seg[e].first+1)*(seg[i-1].second-seg[e].first+1)-(e==0?0:max(0ll,seg[e-1].second-seg[e].first+1)*max(0ll,seg[e-1].second-seg[e].first+1)));
}
}
}
return dp[seg.size()][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... |