# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
108199 |
2019-04-28T03:40:45 Z |
luciocf |
Gap (APIO16_gap) |
C++14 |
|
627 ms |
3576 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
const int maxn = 1e5+10;
const long long maxv = 1e18;
typedef long long ll;
ll a[maxn];
long long findGap(int T, int N)
{
if (T == 1)
{
ll mn, mx;
MinMax(0, maxv, &mn, &mx);
int l = 1, r = N;
a[1] = mn, a[N] = mx;
while (true)
{
if (r-l <= 1) break;
MinMax(a[l]+1, a[r]-1, &mn, &mx);
a[++l] = mn, a[--r] = mx;
}
ll ans = 0;
for (int i = 1; i < N; i++)
ans = max(ans, a[i+1]-a[i]);
return ans;
}
ll s = 0, mn, mx, last;
ll ans = 0;
MinMax(0, maxv, &mn, &mx);
s = mn, last = mx;
while (true)
{
mn = mx = -1;
ll k;
for (ll i = 0; i <= 60 && s+(1LL<<i) <= 2*maxv; i++)
{
ll t = s+(1LL<<i);
MinMax(s+1, t, &mn, &mx);
if (mn != -1 && mx != -1)
{
k = i;
break;
}
}
MinMax(s+1, s+(1LL<<k), &mn, &mx);
ans = max(ans, mn-s);
s = mx;
if (s >= last) break;
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:50:6: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
ll k;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
18 ms |
1044 KB |
Output is correct |
17 |
Correct |
13 ms |
1024 KB |
Output is correct |
18 |
Correct |
16 ms |
1024 KB |
Output is correct |
19 |
Correct |
18 ms |
1024 KB |
Output is correct |
20 |
Correct |
11 ms |
768 KB |
Output is correct |
21 |
Correct |
55 ms |
3576 KB |
Output is correct |
22 |
Correct |
66 ms |
3448 KB |
Output is correct |
23 |
Correct |
53 ms |
3488 KB |
Output is correct |
24 |
Correct |
48 ms |
3572 KB |
Output is correct |
25 |
Correct |
59 ms |
2936 KB |
Output is correct |
26 |
Correct |
55 ms |
3576 KB |
Output is correct |
27 |
Correct |
57 ms |
3576 KB |
Output is correct |
28 |
Correct |
59 ms |
3548 KB |
Output is correct |
29 |
Correct |
47 ms |
3500 KB |
Output is correct |
30 |
Correct |
39 ms |
2380 KB |
Output is correct |
31 |
Correct |
3 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
3 ms |
512 KB |
Partially correct |
2 |
Partially correct |
2 ms |
384 KB |
Partially correct |
3 |
Partially correct |
3 ms |
384 KB |
Partially correct |
4 |
Partially correct |
2 ms |
384 KB |
Partially correct |
5 |
Partially correct |
3 ms |
384 KB |
Partially correct |
6 |
Partially correct |
2 ms |
384 KB |
Partially correct |
7 |
Partially correct |
2 ms |
384 KB |
Partially correct |
8 |
Partially correct |
2 ms |
384 KB |
Partially correct |
9 |
Partially correct |
3 ms |
384 KB |
Partially correct |
10 |
Partially correct |
3 ms |
384 KB |
Partially correct |
11 |
Partially correct |
11 ms |
512 KB |
Partially correct |
12 |
Partially correct |
9 ms |
384 KB |
Partially correct |
13 |
Partially correct |
11 ms |
384 KB |
Partially correct |
14 |
Partially correct |
8 ms |
384 KB |
Partially correct |
15 |
Partially correct |
6 ms |
384 KB |
Partially correct |
16 |
Partially correct |
131 ms |
896 KB |
Partially correct |
17 |
Partially correct |
129 ms |
888 KB |
Partially correct |
18 |
Partially correct |
143 ms |
852 KB |
Partially correct |
19 |
Partially correct |
163 ms |
884 KB |
Partially correct |
20 |
Partially correct |
14 ms |
512 KB |
Partially correct |
21 |
Partially correct |
615 ms |
2936 KB |
Partially correct |
22 |
Partially correct |
518 ms |
2812 KB |
Partially correct |
23 |
Partially correct |
627 ms |
2844 KB |
Partially correct |
24 |
Partially correct |
561 ms |
2908 KB |
Partially correct |
25 |
Partially correct |
449 ms |
2168 KB |
Partially correct |
26 |
Partially correct |
555 ms |
2808 KB |
Partially correct |
27 |
Partially correct |
518 ms |
2816 KB |
Partially correct |
28 |
Partially correct |
586 ms |
2680 KB |
Partially correct |
29 |
Partially correct |
548 ms |
2820 KB |
Partially correct |
30 |
Partially correct |
39 ms |
1532 KB |
Partially correct |
31 |
Partially correct |
2 ms |
384 KB |
Partially correct |
32 |
Partially correct |
3 ms |
384 KB |
Partially correct |