# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
262143 |
2020-08-12T11:54:02 Z |
define |
Gap (APIO16_gap) |
C++17 |
|
85 ms |
1276 KB |
#include "gap.h"
#define ll long long
#include<iostream>
using namespace std;
template<class T>
inline bool chmax(T &a,T b){
if(a<b){a=b;return true;}
return false;
}
ll solve1(int N){
ll ans=0;
ll l=-1,r=1e18;r+=1;
for(int i=0;i<(N+1)/2;i++){
ll mn,mx;
MinMax(l+1,r-1,&mn,&mx);
if(i){
chmax(ans,mn-l);
chmax(ans,r-mx);
}
l=mn;
r=mx;
}
if(N%2==0)chmax(ans,r-l);
return ans;
}
ll solve2(int N){
ll mn,mx;
MinMax(0,1e18,&mn,&mx);
ll sz=(mx-mn+N-1)/N;
ll l=mn+1,r=mn+sz,now=mn;
ll ans=0;
for(int i=0;i<N;i++){
MinMax(l,r,&mn,&mx);
if(mn!=-1){
chmax(ans,mn-now);
now=mx;
}
l+=sz;r+=sz;
}
return ans;
}
ll findGap(int T, int N){
if(T==1)return solve1(N);
return solve2(N);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
13 ms |
512 KB |
Output is correct |
17 |
Correct |
14 ms |
512 KB |
Output is correct |
18 |
Correct |
15 ms |
520 KB |
Output is correct |
19 |
Correct |
13 ms |
512 KB |
Output is correct |
20 |
Correct |
9 ms |
512 KB |
Output is correct |
21 |
Correct |
60 ms |
1144 KB |
Output is correct |
22 |
Correct |
51 ms |
1144 KB |
Output is correct |
23 |
Correct |
58 ms |
1144 KB |
Output is correct |
24 |
Correct |
53 ms |
1144 KB |
Output is correct |
25 |
Correct |
52 ms |
1144 KB |
Output is correct |
26 |
Correct |
51 ms |
1144 KB |
Output is correct |
27 |
Correct |
51 ms |
1084 KB |
Output is correct |
28 |
Correct |
60 ms |
1144 KB |
Output is correct |
29 |
Correct |
51 ms |
1144 KB |
Output is correct |
30 |
Correct |
39 ms |
1272 KB |
Output is correct |
31 |
Correct |
0 ms |
384 KB |
Output is correct |
32 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
416 KB |
Output is correct |
16 |
Correct |
19 ms |
512 KB |
Output is correct |
17 |
Correct |
16 ms |
512 KB |
Output is correct |
18 |
Correct |
16 ms |
512 KB |
Output is correct |
19 |
Correct |
16 ms |
512 KB |
Output is correct |
20 |
Correct |
8 ms |
512 KB |
Output is correct |
21 |
Correct |
69 ms |
1160 KB |
Output is correct |
22 |
Correct |
69 ms |
1276 KB |
Output is correct |
23 |
Correct |
68 ms |
1064 KB |
Output is correct |
24 |
Correct |
85 ms |
1136 KB |
Output is correct |
25 |
Correct |
61 ms |
1144 KB |
Output is correct |
26 |
Correct |
71 ms |
1144 KB |
Output is correct |
27 |
Correct |
67 ms |
1164 KB |
Output is correct |
28 |
Correct |
72 ms |
1060 KB |
Output is correct |
29 |
Correct |
70 ms |
1144 KB |
Output is correct |
30 |
Correct |
42 ms |
1152 KB |
Output is correct |
31 |
Correct |
0 ms |
384 KB |
Output is correct |
32 |
Correct |
0 ms |
384 KB |
Output is correct |