# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
742893 |
2023-05-17T05:40:34 Z |
boyliguanhan |
Gap (APIO16_gap) |
C++17 |
|
62 ms |
1196 KB |
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll findGap(int T, int N)
{
ll l, r, ans=0;
MinMax(0,1e18, &l, &r);
if(T-1) {
ll sz = (r-l+N-2)/(N-1);
ll x,y,z=l;
for(ll i=0;i<N-1;i++) {
if(l+i*sz>=r) break;
MinMax(l+i*sz,min(r,l+(i+1)*sz)-1,&x,&y);
if(x+1)ans=max(ans,x-z),z=y;
}
ans=max(ans,r-z);
} else {
for(ll i=0;i<(N-1>>1);i++) {
ll pl, pr; MinMax(min(r-1,l+1),r-1, &pl, &pr);ans = max(max(pl-l, r-pr), ans);l=pl,r=pr;
}
if(N&1^1)ans=max(ans,r-l);
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:20:24: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
20 | for(ll i=0;i<(N-1>>1);i++) {
| ~^~
gap.cpp:23:13: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
23 | if(N&1^1)ans=max(ans,r-l);
| ~^~
# |
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 |
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 |
1 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 |
0 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 |
208 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 |
10 ms |
464 KB |
Output is correct |
17 |
Correct |
9 ms |
464 KB |
Output is correct |
18 |
Correct |
10 ms |
520 KB |
Output is correct |
19 |
Correct |
10 ms |
464 KB |
Output is correct |
20 |
Correct |
7 ms |
520 KB |
Output is correct |
21 |
Correct |
35 ms |
1088 KB |
Output is correct |
22 |
Correct |
37 ms |
1060 KB |
Output is correct |
23 |
Correct |
39 ms |
1084 KB |
Output is correct |
24 |
Correct |
37 ms |
1084 KB |
Output is correct |
25 |
Correct |
34 ms |
1084 KB |
Output is correct |
26 |
Correct |
41 ms |
1084 KB |
Output is correct |
27 |
Correct |
40 ms |
1084 KB |
Output is correct |
28 |
Correct |
42 ms |
1140 KB |
Output is correct |
29 |
Correct |
36 ms |
956 KB |
Output is correct |
30 |
Correct |
29 ms |
1060 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 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 |
1 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 |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
208 KB |
Output is correct |
16 |
Correct |
13 ms |
500 KB |
Output is correct |
17 |
Correct |
13 ms |
516 KB |
Output is correct |
18 |
Correct |
12 ms |
516 KB |
Output is correct |
19 |
Correct |
13 ms |
456 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
54 ms |
1196 KB |
Output is correct |
22 |
Correct |
48 ms |
976 KB |
Output is correct |
23 |
Correct |
51 ms |
1056 KB |
Output is correct |
24 |
Correct |
50 ms |
1084 KB |
Output is correct |
25 |
Correct |
45 ms |
1068 KB |
Output is correct |
26 |
Correct |
51 ms |
1060 KB |
Output is correct |
27 |
Correct |
49 ms |
1084 KB |
Output is correct |
28 |
Correct |
50 ms |
1084 KB |
Output is correct |
29 |
Correct |
62 ms |
1060 KB |
Output is correct |
30 |
Correct |
29 ms |
1000 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |