# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
761780 |
2023-06-20T09:26:11 Z |
Dan4Life |
Aliens (IOI16_aliens) |
C++17 |
|
1 ms |
212 KB |
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
using ll = long long;
using ar = array<int,2>;
vector<ar> v,w;
ll sq(ll x){return x*x;}
ll cost(int i, int j){
ll x = max(0,v[i][1]-v[j][0]+1); if(i==0) x=0;
return sq(v[j][1]-v[i][0]+1)-sq(x);
}
ll take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
for(int i = 0; i < n; i++)
if(r[i]>c[i]) r[i]=m-r[i]-1,c[i]=m-c[i]-1;
for(int i = 0; i < n; i++) w.pb({r[i],c[i]});
sort(begin(w),end(w),[&](ar a, ar b){
if(a[1]!=b[1]) return a[1]<b[1];
return a[0]>b[0];
});
int mn=m;
for(int i = n-1; i >=0; i--){
if(mn>w[i][0]) v.pb(w[i]);
mn = min(mn,w[i][0]);
}
sort(begin(v),end(v),[&](ar a, ar b){
if(a[1]!=b[1]) return a[1]<b[1];
return a[0]>b[0];
});
n = sz(v); ll dp[k+1][n+1],ans=(ll)4e18; memset(dp,63,sizeof(dp));
for(int i = 0; i < n; i++) dp[1][i] = cost(0,i);
for(int j = 2; j <= k; j++)
for(int i = 0; i < n; i++)
for(int x = 0; x < i; x++)
dp[j][i] = min({dp[j][i], dp[j-1][x]+cost(x+1,i)});
for(int i = 1; i <= k; i++) ans = min(ans, dp[i][n-1]);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
0 ms |
212 KB |
Wrong answer: output = 4, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Correct answer: answer = 1 |
2 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 1 |
4 |
Incorrect |
0 ms |
212 KB |
Wrong answer: output = 4, expected = 5 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
0 ms |
212 KB |
Wrong answer: output = 4, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
0 ms |
212 KB |
Wrong answer: output = 4, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
0 ms |
212 KB |
Wrong answer: output = 4, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
212 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
0 ms |
212 KB |
Wrong answer: output = 4, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |