# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471935 | 2021-09-11T21:53:19 Z | sofapuden | Aliens (IOI16_aliens) | C++14 | 1 ms | 332 KB |
#include "aliens.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = (1ll<<60); bool cmp(pair<ll,ll> &a, pair<ll,ll> &b){ if(a.first == b.first)return a.second > b.second; return a.first < b.first; } ll take_photos(int n, int m, int k, vector<int> r, vector<int> c) { vector<pair<ll,ll>> v(n); for(int i = 0; i < n; ++i){ v[i] = {r[i],c[i]}; } for(int i = 0; i < n; ++i){ if(v[i].first > v[i].second)swap(v[i].first,v[i].second); } sort(v.begin(),v.end(),cmp); ll l = 0, ri = INF, ans = INF, bes, cnt; while(l <= ri){ ll m = (l+ri)>>1; ll st = v[0].first, cu = v[0].second; ll su = (cu-st+1)*(cu-st+1); ll cn = 1; for(int i = 0; i < n; ++i){ if(v[i].second <= cu)continue; ll un = 0; if(v[i].first <= cu){ un = (cu-v[i].first+1)*(cu-v[i].first+1); } if((v[i].second-v[i].first+1)*(v[i].second-v[i].first+1)-un+m < (v[i].second-st+1)*(v[i].second-st+1)-(cu-st+1)*(cu-st+1)){ cn++; su+=(v[i].second-v[i].first+1)*(v[i].second-v[i].first+1)-un; st = v[i].first; cu = v[i].second; } else{ su+=(v[i].second-st+1)*(v[i].second-st+1)-(cu-st+1)*(cu-st+1); cu = v[i].second; } } if(cn < k){ cnt = cn; bes = m; ans = min(ans,su); ri = m-1; } else if(cn == k){ cnt = cn; bes = m; ans = min(ans, su); l = m+1; } else{ l = m+1; } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
2 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
3 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
4 | Correct | 0 ms | 204 KB | Correct answer: answer = 12 |
5 | Correct | 1 ms | 204 KB | Correct answer: answer = 52 |
6 | Correct | 0 ms | 204 KB | Correct answer: answer = 210 |
7 | Correct | 0 ms | 204 KB | Correct answer: answer = 88 |
8 | Correct | 0 ms | 204 KB | Correct answer: answer = 7696 |
9 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
10 | Correct | 0 ms | 204 KB | Correct answer: answer = 2374 |
11 | Correct | 0 ms | 204 KB | Correct answer: answer = 9502 |
12 | Correct | 1 ms | 204 KB | Correct answer: answer = 49 |
13 | Correct | 0 ms | 204 KB | Correct answer: answer = 151 |
14 | Correct | 1 ms | 204 KB | Correct answer: answer = 7550 |
15 | Correct | 1 ms | 204 KB | Correct answer: answer = 7220 |
16 | Correct | 0 ms | 204 KB | Correct answer: answer = 7550 |
17 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
18 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
19 | Correct | 0 ms | 204 KB | Correct answer: answer = 624 |
20 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 268 KB | Correct answer: answer = 1 |
2 | Correct | 0 ms | 216 KB | Correct answer: answer = 4 |
3 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
4 | Correct | 0 ms | 204 KB | Correct answer: answer = 5 |
5 | Incorrect | 1 ms | 332 KB | Wrong answer: output = 53, expected = 41 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
2 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
3 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
4 | Correct | 0 ms | 204 KB | Correct answer: answer = 12 |
5 | Correct | 1 ms | 204 KB | Correct answer: answer = 52 |
6 | Correct | 0 ms | 204 KB | Correct answer: answer = 210 |
7 | Correct | 0 ms | 204 KB | Correct answer: answer = 88 |
8 | Correct | 0 ms | 204 KB | Correct answer: answer = 7696 |
9 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
10 | Correct | 0 ms | 204 KB | Correct answer: answer = 2374 |
11 | Correct | 0 ms | 204 KB | Correct answer: answer = 9502 |
12 | Correct | 1 ms | 204 KB | Correct answer: answer = 49 |
13 | Correct | 0 ms | 204 KB | Correct answer: answer = 151 |
14 | Correct | 1 ms | 204 KB | Correct answer: answer = 7550 |
15 | Correct | 1 ms | 204 KB | Correct answer: answer = 7220 |
16 | Correct | 0 ms | 204 KB | Correct answer: answer = 7550 |
17 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
18 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
19 | Correct | 0 ms | 204 KB | Correct answer: answer = 624 |
20 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
21 | Correct | 1 ms | 268 KB | Correct answer: answer = 1 |
22 | Correct | 0 ms | 216 KB | Correct answer: answer = 4 |
23 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
24 | Correct | 0 ms | 204 KB | Correct answer: answer = 5 |
25 | Incorrect | 1 ms | 332 KB | Wrong answer: output = 53, expected = 41 |
26 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
2 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
3 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
4 | Correct | 0 ms | 204 KB | Correct answer: answer = 12 |
5 | Correct | 1 ms | 204 KB | Correct answer: answer = 52 |
6 | Correct | 0 ms | 204 KB | Correct answer: answer = 210 |
7 | Correct | 0 ms | 204 KB | Correct answer: answer = 88 |
8 | Correct | 0 ms | 204 KB | Correct answer: answer = 7696 |
9 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
10 | Correct | 0 ms | 204 KB | Correct answer: answer = 2374 |
11 | Correct | 0 ms | 204 KB | Correct answer: answer = 9502 |
12 | Correct | 1 ms | 204 KB | Correct answer: answer = 49 |
13 | Correct | 0 ms | 204 KB | Correct answer: answer = 151 |
14 | Correct | 1 ms | 204 KB | Correct answer: answer = 7550 |
15 | Correct | 1 ms | 204 KB | Correct answer: answer = 7220 |
16 | Correct | 0 ms | 204 KB | Correct answer: answer = 7550 |
17 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
18 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
19 | Correct | 0 ms | 204 KB | Correct answer: answer = 624 |
20 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
21 | Correct | 1 ms | 268 KB | Correct answer: answer = 1 |
22 | Correct | 0 ms | 216 KB | Correct answer: answer = 4 |
23 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
24 | Correct | 0 ms | 204 KB | Correct answer: answer = 5 |
25 | Incorrect | 1 ms | 332 KB | Wrong answer: output = 53, expected = 41 |
26 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
2 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
3 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
4 | Correct | 0 ms | 204 KB | Correct answer: answer = 12 |
5 | Correct | 1 ms | 204 KB | Correct answer: answer = 52 |
6 | Correct | 0 ms | 204 KB | Correct answer: answer = 210 |
7 | Correct | 0 ms | 204 KB | Correct answer: answer = 88 |
8 | Correct | 0 ms | 204 KB | Correct answer: answer = 7696 |
9 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
10 | Correct | 0 ms | 204 KB | Correct answer: answer = 2374 |
11 | Correct | 0 ms | 204 KB | Correct answer: answer = 9502 |
12 | Correct | 1 ms | 204 KB | Correct answer: answer = 49 |
13 | Correct | 0 ms | 204 KB | Correct answer: answer = 151 |
14 | Correct | 1 ms | 204 KB | Correct answer: answer = 7550 |
15 | Correct | 1 ms | 204 KB | Correct answer: answer = 7220 |
16 | Correct | 0 ms | 204 KB | Correct answer: answer = 7550 |
17 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
18 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
19 | Correct | 0 ms | 204 KB | Correct answer: answer = 624 |
20 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
21 | Correct | 1 ms | 268 KB | Correct answer: answer = 1 |
22 | Correct | 0 ms | 216 KB | Correct answer: answer = 4 |
23 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
24 | Correct | 0 ms | 204 KB | Correct answer: answer = 5 |
25 | Incorrect | 1 ms | 332 KB | Wrong answer: output = 53, expected = 41 |
26 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
2 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
3 | Correct | 0 ms | 204 KB | Correct answer: answer = 4 |
4 | Correct | 0 ms | 204 KB | Correct answer: answer = 12 |
5 | Correct | 1 ms | 204 KB | Correct answer: answer = 52 |
6 | Correct | 0 ms | 204 KB | Correct answer: answer = 210 |
7 | Correct | 0 ms | 204 KB | Correct answer: answer = 88 |
8 | Correct | 0 ms | 204 KB | Correct answer: answer = 7696 |
9 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
10 | Correct | 0 ms | 204 KB | Correct answer: answer = 2374 |
11 | Correct | 0 ms | 204 KB | Correct answer: answer = 9502 |
12 | Correct | 1 ms | 204 KB | Correct answer: answer = 49 |
13 | Correct | 0 ms | 204 KB | Correct answer: answer = 151 |
14 | Correct | 1 ms | 204 KB | Correct answer: answer = 7550 |
15 | Correct | 1 ms | 204 KB | Correct answer: answer = 7220 |
16 | Correct | 0 ms | 204 KB | Correct answer: answer = 7550 |
17 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
18 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
19 | Correct | 0 ms | 204 KB | Correct answer: answer = 624 |
20 | Correct | 1 ms | 204 KB | Correct answer: answer = 10000 |
21 | Correct | 1 ms | 268 KB | Correct answer: answer = 1 |
22 | Correct | 0 ms | 216 KB | Correct answer: answer = 4 |
23 | Correct | 0 ms | 204 KB | Correct answer: answer = 1 |
24 | Correct | 0 ms | 204 KB | Correct answer: answer = 5 |
25 | Incorrect | 1 ms | 332 KB | Wrong answer: output = 53, expected = 41 |
26 | Halted | 0 ms | 0 KB | - |