#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
const long long inf=1e18;
long long findGap(int T,int N){
if(T==2){
long long min1,max1;
MinMax(0,inf,&min1,&max1);
long long num=max1-min1-1;
assert(num>=N-2);
long long val=num/(N-1),cnt=num%(N-1);
long long ans=val,now=min1+1,now1,dum,dum1;
vector<long long> ans_lis;
ans_lis.push_back(min1);
for(int i=1;i<N;i++){
now1=now+val-1;
if(cnt){
cnt--;
now1++;
}
if(now<=now1){
MinMax(now,now1,&dum,&dum1);
now=now1+1;
if(dum!=-1){
ans_lis.push_back(dum);
ans_lis.push_back(dum1);
}
}
}
ans_lis.push_back(max1);
for(int i=0;i<ans_lis.size()-1;i++){
ans=max(ans,ans_lis[i+1]-ans_lis[i]);
}
return ans;
}
else{
long long min1=-1,max1=inf+1,ans=0;
vector<long long> ans_lis,ans_lis1;
for(int i=1;i<=(N+1)/2;i++){
assert(min1+1<=max1-1);
MinMax(min1+1,max1-1,&min1,&max1);
assert(min1!=-1&&max1!=-1);
ans_lis.push_back(min1);
ans_lis1.push_back(max1);
}
while(ans_lis1.size()){
ans_lis.push_back(ans_lis1.back());
ans_lis1.pop_back();
}
for(int i=0;i+1<ans_lis.size();i++){
ans=max(ans,ans_lis[i+1]-ans_lis[i]);
}
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:31:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<ans_lis.size()-1;i++){
~^~~~~~~~~~~~~~~~~
gap.cpp:50:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i+1<ans_lis.size();i++){
~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
13 |
Correct |
3 ms |
472 KB |
Output is correct |
14 |
Correct |
3 ms |
380 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
16 ms |
1444 KB |
Output is correct |
17 |
Correct |
17 ms |
1444 KB |
Output is correct |
18 |
Correct |
41 ms |
1452 KB |
Output is correct |
19 |
Correct |
16 ms |
1444 KB |
Output is correct |
20 |
Correct |
12 ms |
1188 KB |
Output is correct |
21 |
Correct |
58 ms |
4504 KB |
Output is correct |
22 |
Correct |
59 ms |
4508 KB |
Output is correct |
23 |
Correct |
58 ms |
4476 KB |
Output is correct |
24 |
Correct |
61 ms |
4380 KB |
Output is correct |
25 |
Correct |
51 ms |
3916 KB |
Output is correct |
26 |
Correct |
58 ms |
4500 KB |
Output is correct |
27 |
Correct |
60 ms |
4552 KB |
Output is correct |
28 |
Correct |
59 ms |
4508 KB |
Output is correct |
29 |
Correct |
57 ms |
4504 KB |
Output is correct |
30 |
Correct |
43 ms |
3352 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
380 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
380 KB |
Output is correct |
16 |
Correct |
20 ms |
1400 KB |
Output is correct |
17 |
Correct |
21 ms |
1400 KB |
Output is correct |
18 |
Correct |
20 ms |
1400 KB |
Output is correct |
19 |
Correct |
20 ms |
1400 KB |
Output is correct |
20 |
Correct |
10 ms |
760 KB |
Output is correct |
21 |
Correct |
78 ms |
4204 KB |
Output is correct |
22 |
Correct |
76 ms |
4208 KB |
Output is correct |
23 |
Correct |
78 ms |
4204 KB |
Output is correct |
24 |
Correct |
78 ms |
4152 KB |
Output is correct |
25 |
Correct |
75 ms |
4460 KB |
Output is correct |
26 |
Correct |
78 ms |
4336 KB |
Output is correct |
27 |
Correct |
76 ms |
4080 KB |
Output is correct |
28 |
Correct |
77 ms |
4208 KB |
Output is correct |
29 |
Correct |
80 ms |
4172 KB |
Output is correct |
30 |
Correct |
42 ms |
2168 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |