# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
390964 |
2021-04-17T12:45:12 Z |
Blagojce |
Gap (APIO16_gap) |
C++11 |
|
65 ms |
2236 KB |
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int mxn = 1e5;
#include "gap.h"
long long findGap(int T, int N)
{
if(T == 1){
ll lb = 0, rb = (1e18);
vector<ll> v;
fr(i, 0, (int)((N+1)/2)){
ll llb, rrb;
MinMax(lb, rb, &llb, &rrb);
if(llb == -1) break;
v.pb(llb);
v.pb(rrb);
lb = llb+1;
rb = rrb-1;
}
sort(all(v));
ll ans = 0;
fr(i, 0, (int)v.size()-1){
ans = max(ans, v[i+1]-v[i]);
}
return ans;
}
ll a1, an;
MinMax(0, 1e18, &a1, &an);
ll d = (an - a1 + N - 2)/(N-1);
ll pr = a1;
ll ans = d;
for(ll i = 0; a1 + 1 + i*d < an; i++){
ll ai, aj;
MinMax(a1+1 + i*d, min(a1 + (i+1)*d, an-1), &ai, &aj);
if(ai != -1){
ans = max(ans, ai-pr);
pr = aj;
}
}
ans = max(ans, an-pr);
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 |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
2 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
13 ms |
840 KB |
Output is correct |
17 |
Correct |
12 ms |
840 KB |
Output is correct |
18 |
Correct |
14 ms |
840 KB |
Output is correct |
19 |
Correct |
14 ms |
804 KB |
Output is correct |
20 |
Correct |
12 ms |
820 KB |
Output is correct |
21 |
Correct |
62 ms |
2188 KB |
Output is correct |
22 |
Correct |
49 ms |
2196 KB |
Output is correct |
23 |
Correct |
50 ms |
2184 KB |
Output is correct |
24 |
Correct |
49 ms |
2232 KB |
Output is correct |
25 |
Correct |
59 ms |
2232 KB |
Output is correct |
26 |
Correct |
55 ms |
2184 KB |
Output is correct |
27 |
Correct |
65 ms |
2232 KB |
Output is correct |
28 |
Correct |
52 ms |
2236 KB |
Output is correct |
29 |
Correct |
49 ms |
2188 KB |
Output is correct |
30 |
Correct |
42 ms |
2168 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 |
0 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 |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
15 ms |
424 KB |
Output is correct |
17 |
Correct |
15 ms |
456 KB |
Output is correct |
18 |
Correct |
16 ms |
504 KB |
Output is correct |
19 |
Correct |
17 ms |
408 KB |
Output is correct |
20 |
Correct |
8 ms |
456 KB |
Output is correct |
21 |
Correct |
65 ms |
1080 KB |
Output is correct |
22 |
Correct |
62 ms |
1076 KB |
Output is correct |
23 |
Correct |
60 ms |
960 KB |
Output is correct |
24 |
Correct |
60 ms |
968 KB |
Output is correct |
25 |
Correct |
55 ms |
1076 KB |
Output is correct |
26 |
Correct |
60 ms |
960 KB |
Output is correct |
27 |
Correct |
60 ms |
960 KB |
Output is correct |
28 |
Correct |
60 ms |
1040 KB |
Output is correct |
29 |
Correct |
61 ms |
1052 KB |
Output is correct |
30 |
Correct |
34 ms |
1068 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |