# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
22017 |
2017-04-28T20:47:19 Z |
Hiasat |
Gap (APIO16_gap) |
C++14 |
|
63 ms |
6772 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v;
long long findGap(int T, int N) {
ll mx = 0;
if(T == 2){
ll lo,hi;
MinMax(1, 1e18, &lo, &hi);
ll big = hi;
ll sure = (hi-lo)/(N-1) + ((hi-lo)%(N-1) != 0);
ll cur = lo;
ll ed = lo + sure;
ll prev = -1;
ll step = sure;
while(cur + step< big){
MinMax(cur, ed, &lo, &hi);
if(hi == -1 || hi == cur){
ed = ed + step;
continue;
}
step = max(step,hi - lo);
if(prev != -1){
step = max(step,lo - prev);
}
prev = hi;
cur = hi+1;
ed = cur + step;
}
return step;
}else{
ll lo = 1, hi = 1e18;
int rem =(N+1)/2;
while(rem--){
ll a , b;
MinMax(lo,hi,&a,&b);
if(a == -1)
break;
v.push_back(a);
v.push_back(b);
lo = a+1;
hi = b-1;
}
}
sort(v.begin(),v.end());
for (int i = 0; i+1 < v.size(); ++i){
mx = max(mx,v[i+1]-v[i]);
}
return mx;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:52:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i+1 < v.size(); ++i){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5148 KB |
Output is correct |
2 |
Correct |
0 ms |
5148 KB |
Output is correct |
3 |
Correct |
0 ms |
5148 KB |
Output is correct |
4 |
Correct |
0 ms |
5148 KB |
Output is correct |
5 |
Correct |
0 ms |
5148 KB |
Output is correct |
6 |
Correct |
0 ms |
5148 KB |
Output is correct |
7 |
Correct |
0 ms |
5148 KB |
Output is correct |
8 |
Correct |
0 ms |
5148 KB |
Output is correct |
9 |
Correct |
0 ms |
5148 KB |
Output is correct |
10 |
Correct |
0 ms |
5148 KB |
Output is correct |
11 |
Correct |
0 ms |
5148 KB |
Output is correct |
12 |
Correct |
0 ms |
5148 KB |
Output is correct |
13 |
Correct |
0 ms |
5148 KB |
Output is correct |
14 |
Correct |
0 ms |
5148 KB |
Output is correct |
15 |
Correct |
0 ms |
5148 KB |
Output is correct |
16 |
Correct |
16 ms |
5620 KB |
Output is correct |
17 |
Correct |
9 ms |
5620 KB |
Output is correct |
18 |
Correct |
16 ms |
5620 KB |
Output is correct |
19 |
Correct |
13 ms |
5620 KB |
Output is correct |
20 |
Correct |
9 ms |
5620 KB |
Output is correct |
21 |
Correct |
53 ms |
6772 KB |
Output is correct |
22 |
Correct |
59 ms |
6772 KB |
Output is correct |
23 |
Correct |
63 ms |
6772 KB |
Output is correct |
24 |
Correct |
53 ms |
6772 KB |
Output is correct |
25 |
Correct |
53 ms |
6772 KB |
Output is correct |
26 |
Correct |
49 ms |
6772 KB |
Output is correct |
27 |
Correct |
56 ms |
6772 KB |
Output is correct |
28 |
Correct |
56 ms |
6772 KB |
Output is correct |
29 |
Correct |
53 ms |
6772 KB |
Output is correct |
30 |
Correct |
53 ms |
6772 KB |
Output is correct |
31 |
Correct |
0 ms |
5148 KB |
Output is correct |
32 |
Correct |
0 ms |
5148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5148 KB |
Output is correct |
2 |
Correct |
0 ms |
5148 KB |
Output is correct |
3 |
Correct |
0 ms |
5148 KB |
Output is correct |
4 |
Correct |
0 ms |
5148 KB |
Output is correct |
5 |
Correct |
0 ms |
5148 KB |
Output is correct |
6 |
Correct |
0 ms |
5148 KB |
Output is correct |
7 |
Correct |
0 ms |
5148 KB |
Output is correct |
8 |
Correct |
0 ms |
5148 KB |
Output is correct |
9 |
Correct |
0 ms |
5148 KB |
Output is correct |
10 |
Correct |
0 ms |
5148 KB |
Output is correct |
11 |
Correct |
0 ms |
5148 KB |
Output is correct |
12 |
Correct |
0 ms |
5148 KB |
Output is correct |
13 |
Correct |
0 ms |
5148 KB |
Output is correct |
14 |
Correct |
0 ms |
5148 KB |
Output is correct |
15 |
Correct |
0 ms |
5148 KB |
Output is correct |
16 |
Correct |
6 ms |
5148 KB |
Output is correct |
17 |
Correct |
6 ms |
5148 KB |
Output is correct |
18 |
Correct |
6 ms |
5148 KB |
Output is correct |
19 |
Correct |
6 ms |
5148 KB |
Output is correct |
20 |
Correct |
3 ms |
5148 KB |
Output is correct |
21 |
Correct |
33 ms |
5148 KB |
Output is correct |
22 |
Correct |
36 ms |
5148 KB |
Output is correct |
23 |
Correct |
33 ms |
5148 KB |
Output is correct |
24 |
Correct |
36 ms |
5148 KB |
Output is correct |
25 |
Correct |
63 ms |
5148 KB |
Output is correct |
26 |
Correct |
29 ms |
5148 KB |
Output is correct |
27 |
Correct |
33 ms |
5148 KB |
Output is correct |
28 |
Correct |
43 ms |
5148 KB |
Output is correct |
29 |
Correct |
26 ms |
5148 KB |
Output is correct |
30 |
Correct |
23 ms |
5148 KB |
Output is correct |
31 |
Correct |
0 ms |
5148 KB |
Output is correct |
32 |
Correct |
0 ms |
5148 KB |
Output is correct |