#include<bits/stdc++.h>
#include "gap.h"
#define MAXN 600007
using namespace std;
const long long inf=1e18;
long long *l,*r,*ll,*rr;
long long d,ans;
vector<long long> v;
long long findGap(int T, int N){
l=new long long();
r=new long long();
MinMax(1, inf, l,r);
if(T==1){
v.push_back(*l);
v.push_back(*r);
for(int i=1;i<=N;i++){
ll=new long long();
rr=new long long();
MinMax((*l)+1,(*r)-1,ll,rr);
if((*ll)==-1)break;
v.push_back(*ll);
v.push_back(*rr);
l=ll; r=rr;
}
sort(v.begin(),v.end());
for(int i=0;i<v.size()-1;i++){
ans=max(ans,v[i+1]-v[i]);
}
return ans;
}
d=ans=(long long) (*r-*l)/(N-1);
while(*l!=*r){
while(true){
ll=new long long();
rr=new long long();
MinMax((*l)+1,(*l)+d+1,ll,rr);
if((*ll)!=-1)break;
d*=2;
}
ans=max(ans,*ll-*l);
d=ans;
l=rr;
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i=0;i<v.size()-1;i++){
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
5 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
6 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
10 |
Runtime error |
1 ms |
344 KB |
Execution failed because the return code was nonzero |
11 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
16 |
Incorrect |
8 ms |
1520 KB |
Output isn't correct |
17 |
Incorrect |
10 ms |
1492 KB |
Output isn't correct |
18 |
Incorrect |
8 ms |
1492 KB |
Output isn't correct |
19 |
Incorrect |
9 ms |
1492 KB |
Output isn't correct |
20 |
Runtime error |
6 ms |
1492 KB |
Execution failed because the return code was nonzero |
21 |
Incorrect |
35 ms |
5064 KB |
Output isn't correct |
22 |
Incorrect |
31 ms |
5068 KB |
Output isn't correct |
23 |
Incorrect |
32 ms |
5068 KB |
Output isn't correct |
24 |
Incorrect |
31 ms |
5092 KB |
Output isn't correct |
25 |
Incorrect |
28 ms |
5068 KB |
Output isn't correct |
26 |
Incorrect |
31 ms |
5068 KB |
Output isn't correct |
27 |
Incorrect |
30 ms |
4916 KB |
Output isn't correct |
28 |
Incorrect |
31 ms |
5060 KB |
Output isn't correct |
29 |
Incorrect |
32 ms |
5060 KB |
Output isn't correct |
30 |
Runtime error |
29 ms |
5068 KB |
Execution failed because the return code was nonzero |
31 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
32 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
5 ms |
756 KB |
Output is correct |
17 |
Correct |
5 ms |
600 KB |
Output is correct |
18 |
Correct |
4 ms |
600 KB |
Output is correct |
19 |
Correct |
5 ms |
600 KB |
Output is correct |
20 |
Correct |
3 ms |
600 KB |
Output is correct |
21 |
Correct |
22 ms |
1572 KB |
Output is correct |
22 |
Correct |
23 ms |
1872 KB |
Output is correct |
23 |
Correct |
17 ms |
1824 KB |
Output is correct |
24 |
Correct |
17 ms |
1624 KB |
Output is correct |
25 |
Correct |
46 ms |
7412 KB |
Output is correct |
26 |
Correct |
18 ms |
1880 KB |
Output is correct |
27 |
Correct |
18 ms |
1880 KB |
Output is correct |
28 |
Correct |
29 ms |
1872 KB |
Output is correct |
29 |
Correct |
18 ms |
1624 KB |
Output is correct |
30 |
Correct |
9 ms |
1368 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |