# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
579532 |
2022-06-19T10:30:02 Z |
jiahng |
Gap (APIO16_gap) |
C++14 |
|
50 ms |
1900 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
typedef pair<int32_t, int32_t> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 200010
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
ll arr[100001];
long long findGap(int T, int N)
{
if (T == 1){
ll curs = 0, curt = 1e18;
FOR(i,0,(N+1)/2 - 1){
MinMax(curs,curt,arr + i, arr + N - i - 1);
curs = arr[i] + 1;
curt = arr[N - i - 1] - 1;
}
ll ans = 0;
FOR(i,0,N-2) ans = max(ans,arr[i+1] - arr[i]);
return ans;
}
ll mx, ans = 1, x = 0, _;
ll empty_num = 0;
MinMax(0,(ll)1e18,&x,&mx);
ans = (mx - x) / N + 1;
while (x < mx){
ll amt = ans, res = -1, y;
while (res == -1){
MinMax(x+1,min(mx, x+amt),&res,&y);
empty_num += (res == -1);
if (x + amt >= mx) break;
amt <<= 1;
}
if (res == -1) break;
ans = max(ans, res - x);
x = y;
}
assert(empty_num <= N+70);
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:47:28: warning: unused variable '_' [-Wunused-variable]
47 | ll mx, ans = 1, x = 0, _;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
224 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
592 KB |
Output is correct |
17 |
Correct |
11 ms |
596 KB |
Output is correct |
18 |
Correct |
11 ms |
592 KB |
Output is correct |
19 |
Correct |
10 ms |
588 KB |
Output is correct |
20 |
Correct |
9 ms |
704 KB |
Output is correct |
21 |
Correct |
46 ms |
1836 KB |
Output is correct |
22 |
Correct |
44 ms |
1820 KB |
Output is correct |
23 |
Correct |
41 ms |
1756 KB |
Output is correct |
24 |
Correct |
38 ms |
1900 KB |
Output is correct |
25 |
Correct |
34 ms |
1852 KB |
Output is correct |
26 |
Correct |
42 ms |
1832 KB |
Output is correct |
27 |
Correct |
40 ms |
1864 KB |
Output is correct |
28 |
Correct |
42 ms |
1736 KB |
Output is correct |
29 |
Correct |
39 ms |
1780 KB |
Output is correct |
30 |
Correct |
33 ms |
1808 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
7 ms |
520 KB |
Output is correct |
17 |
Correct |
6 ms |
544 KB |
Output is correct |
18 |
Correct |
8 ms |
464 KB |
Output is correct |
19 |
Correct |
7 ms |
504 KB |
Output is correct |
20 |
Correct |
3 ms |
464 KB |
Output is correct |
21 |
Correct |
25 ms |
1048 KB |
Output is correct |
22 |
Correct |
31 ms |
1040 KB |
Output is correct |
23 |
Correct |
24 ms |
1000 KB |
Output is correct |
24 |
Correct |
25 ms |
1060 KB |
Output is correct |
25 |
Correct |
50 ms |
1096 KB |
Output is correct |
26 |
Correct |
26 ms |
972 KB |
Output is correct |
27 |
Correct |
29 ms |
1064 KB |
Output is correct |
28 |
Correct |
32 ms |
968 KB |
Output is correct |
29 |
Correct |
31 ms |
1052 KB |
Output is correct |
30 |
Correct |
14 ms |
1064 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |