# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
398268 |
2021-05-04T04:19:33 Z |
tengiz05 |
Gap (APIO16_gap) |
C++17 |
|
71 ms |
1956 KB |
#ifndef EVAL
#include "grader.cpp"
#endif
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll findGap(int T, int n){
if(T == 1){
ll ans = 0;
ll l=0, r=1e18;
vector<ll> a(n+1);
ll mn, mx;
int idl = 1, idr = n;
while(idl <= idr){
MinMax(l, r, &mn, &mx);
a[idl] = mn;
a[idr] = mx;
l = mn+1, r = mx-1;
idl++;
idr--;
}
for(int i=2;i<=n;i++)ans = max(ans, a[i]-a[i-1]);
return ans;
}else {
ll l=0, r=1e18;
MinMax(l,r,&l,&r);
if(r-l+1 == n){
return 1;
}
ll len = (r-l+1)/n;
if((r-l+1)%n)len++;
ll ans = len;
ll last = l;
for(ll i=l;i<=r;i+=len){
ll askl = i;
if(askl == l)askl++;
ll mn,mx;
//~ cerr << "what the\n";
MinMax(askl,min(i+len-1,r),&mn,&mx);
//~ cerr << "OK\n";
if(mn == -1)continue;
ans = max(ans,mx-mn);
ans = max(ans,mn - last);
last = mx;
//~ cout << ans << '\n';
}
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
11 ms |
716 KB |
Output is correct |
17 |
Correct |
12 ms |
712 KB |
Output is correct |
18 |
Correct |
13 ms |
680 KB |
Output is correct |
19 |
Correct |
11 ms |
680 KB |
Output is correct |
20 |
Correct |
9 ms |
712 KB |
Output is correct |
21 |
Correct |
44 ms |
1816 KB |
Output is correct |
22 |
Correct |
48 ms |
1776 KB |
Output is correct |
23 |
Correct |
55 ms |
1760 KB |
Output is correct |
24 |
Correct |
44 ms |
1956 KB |
Output is correct |
25 |
Correct |
37 ms |
1832 KB |
Output is correct |
26 |
Correct |
42 ms |
1848 KB |
Output is correct |
27 |
Correct |
55 ms |
1812 KB |
Output is correct |
28 |
Correct |
43 ms |
1824 KB |
Output is correct |
29 |
Correct |
43 ms |
1864 KB |
Output is correct |
30 |
Correct |
38 ms |
1824 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
14 ms |
492 KB |
Output is correct |
17 |
Correct |
15 ms |
456 KB |
Output is correct |
18 |
Correct |
15 ms |
456 KB |
Output is correct |
19 |
Correct |
14 ms |
456 KB |
Output is correct |
20 |
Correct |
8 ms |
456 KB |
Output is correct |
21 |
Correct |
60 ms |
996 KB |
Output is correct |
22 |
Correct |
60 ms |
1092 KB |
Output is correct |
23 |
Correct |
60 ms |
1120 KB |
Output is correct |
24 |
Correct |
65 ms |
1056 KB |
Output is correct |
25 |
Correct |
63 ms |
1056 KB |
Output is correct |
26 |
Correct |
60 ms |
1056 KB |
Output is correct |
27 |
Correct |
59 ms |
1060 KB |
Output is correct |
28 |
Correct |
59 ms |
1064 KB |
Output is correct |
29 |
Correct |
71 ms |
1028 KB |
Output is correct |
30 |
Correct |
35 ms |
1060 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |