# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1050609 |
2024-08-09T11:44:16 Z |
matere |
Gap (APIO16_gap) |
C++14 |
|
38 ms |
2864 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int T, int N){
if(T==1){
long long mn=-1,mx=-1;
MinMax(1,1000000000000000000,&mn,&mx);
long long premn=mn,premx=mx;
long long ans=0;
for(int i=1;i<(N+1)/2;i++){
premn=mn,premx=mx;
MinMax(mn+1,mx-1,&mn,&mx);
ans=max(ans,mn-premn);
ans=max(ans,premx-mx);
}
ans=max(ans,mx-mn);
return ans;
}
long long mn=-1,mx=-1;
MinMax(1,1000000000000000000,&mn,&mx);
long long diff = mx-mn;
long long mxx = mx;
long long mnd=(diff+N-2)/(N-1);
long long ans=mnd,curm=mn;
for(long long i=mn+1;i<=mxx-1;i+=mnd){
// cout<<i<<' '<<i+mnd-1<<' ';
MinMax(i,min(mxx-1,i+mnd-1),&mn,&mx);
// cout<<mn<<' '<<mx<<endl;
if(mn==-1) continue;
// cout<<mn<<' '<<curm<<endl;
ans=max(ans,mn-curm);
curm=mx;
}
ans=max(ans,mxx-curm);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2388 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
0 ms |
2392 KB |
Output is correct |
12 |
Correct |
0 ms |
2392 KB |
Output is correct |
13 |
Correct |
0 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
0 ms |
2392 KB |
Output is correct |
16 |
Correct |
5 ms |
2588 KB |
Output is correct |
17 |
Correct |
6 ms |
2388 KB |
Output is correct |
18 |
Correct |
6 ms |
2392 KB |
Output is correct |
19 |
Correct |
7 ms |
2576 KB |
Output is correct |
20 |
Correct |
5 ms |
2392 KB |
Output is correct |
21 |
Correct |
26 ms |
2848 KB |
Output is correct |
22 |
Correct |
26 ms |
2652 KB |
Output is correct |
23 |
Correct |
21 ms |
2648 KB |
Output is correct |
24 |
Correct |
22 ms |
2648 KB |
Output is correct |
25 |
Correct |
21 ms |
2648 KB |
Output is correct |
26 |
Correct |
21 ms |
2648 KB |
Output is correct |
27 |
Correct |
30 ms |
2736 KB |
Output is correct |
28 |
Correct |
22 ms |
2864 KB |
Output is correct |
29 |
Correct |
21 ms |
2844 KB |
Output is correct |
30 |
Correct |
22 ms |
2648 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2392 KB |
Output is correct |
6 |
Correct |
0 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2488 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
7 ms |
2508 KB |
Output is correct |
17 |
Correct |
7 ms |
2392 KB |
Output is correct |
18 |
Correct |
7 ms |
2584 KB |
Output is correct |
19 |
Correct |
7 ms |
2392 KB |
Output is correct |
20 |
Correct |
5 ms |
2392 KB |
Output is correct |
21 |
Correct |
29 ms |
2832 KB |
Output is correct |
22 |
Correct |
29 ms |
2648 KB |
Output is correct |
23 |
Correct |
29 ms |
2648 KB |
Output is correct |
24 |
Correct |
38 ms |
2648 KB |
Output is correct |
25 |
Correct |
27 ms |
2648 KB |
Output is correct |
26 |
Correct |
30 ms |
2648 KB |
Output is correct |
27 |
Correct |
29 ms |
2648 KB |
Output is correct |
28 |
Correct |
30 ms |
2860 KB |
Output is correct |
29 |
Correct |
29 ms |
2648 KB |
Output is correct |
30 |
Correct |
18 ms |
2648 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |