#include <bits/stdc++.h>
//#include "grader.cpp"
#include "gap.h"
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define lol long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((lol)(1e15+100))
#define MX ((lol)(4e9+100))
#define ARRS ((lol)(1e6+100))
#define MOD ((lol)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 21
long long findGap(int T, int n)
{
if(T==2){
vector<ll> v;
ll k,p;
MinMax(0,1e18,&k,&p);
v.pb(k);
v.pb(p);
if(n>2){
ll l=k+1,r=p-1;
ll t=(r-l+n)/(n-1);
t=max(t,1ll);
for(ll i=l; i<=r; i+=t){
MinMax(i,min(r,i+t-1),&k,&p);
if(k<0)continue;
v.pb(k);
v.pb(p);
}
}
sort(v.begin(),v.end());
ll pas=0;
for(int i=1; i<v.size(); i++)
pas=max(pas,v[i]-v[i-1]);
return pas;
}
else {
vector<ll> v;
ll k,p;
ll l=0,r=1e18;
while(l<=r){
MinMax(l,r,&k,&p);
if(k<0)continue;
v.pb(k);
v.pb(p);
l=k+1;
r=p-1;
}
sort(v.begin(),v.end());
ll pas=0;
for(int i=1; i<v.size(); i++)
pas=max(pas,v[i]-v[i-1]);
return pas;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:50:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1; i<v.size(); i++)
~^~~~~~~~~
gap.cpp:69:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1; i<v.size(); i++)
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2056 ms |
248 KB |
Time limit exceeded |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
2 ms |
448 KB |
Output is correct |
5 |
Correct |
2 ms |
484 KB |
Output is correct |
6 |
Execution timed out |
2047 ms |
488 KB |
Time limit exceeded |
7 |
Execution timed out |
2057 ms |
544 KB |
Time limit exceeded |
8 |
Execution timed out |
2056 ms |
560 KB |
Time limit exceeded |
9 |
Execution timed out |
2041 ms |
560 KB |
Time limit exceeded |
10 |
Correct |
2 ms |
616 KB |
Output is correct |
11 |
Execution timed out |
2056 ms |
616 KB |
Time limit exceeded |
12 |
Execution timed out |
2075 ms |
636 KB |
Time limit exceeded |
13 |
Execution timed out |
2082 ms |
636 KB |
Time limit exceeded |
14 |
Execution timed out |
2077 ms |
640 KB |
Time limit exceeded |
15 |
Execution timed out |
2056 ms |
640 KB |
Time limit exceeded |
16 |
Execution timed out |
2063 ms |
1152 KB |
Time limit exceeded |
17 |
Execution timed out |
2078 ms |
1152 KB |
Time limit exceeded |
18 |
Execution timed out |
2086 ms |
1152 KB |
Time limit exceeded |
19 |
Execution timed out |
2073 ms |
1152 KB |
Time limit exceeded |
20 |
Correct |
13 ms |
1152 KB |
Output is correct |
21 |
Execution timed out |
2067 ms |
2548 KB |
Time limit exceeded |
22 |
Execution timed out |
2064 ms |
2548 KB |
Time limit exceeded |
23 |
Execution timed out |
2063 ms |
2548 KB |
Time limit exceeded |
24 |
Execution timed out |
2082 ms |
2548 KB |
Time limit exceeded |
25 |
Execution timed out |
2048 ms |
2548 KB |
Time limit exceeded |
26 |
Execution timed out |
2053 ms |
2548 KB |
Time limit exceeded |
27 |
Execution timed out |
2054 ms |
2548 KB |
Time limit exceeded |
28 |
Execution timed out |
2075 ms |
2548 KB |
Time limit exceeded |
29 |
Execution timed out |
2072 ms |
2548 KB |
Time limit exceeded |
30 |
Correct |
45 ms |
2548 KB |
Output is correct |
31 |
Correct |
2 ms |
2548 KB |
Output is correct |
32 |
Correct |
2 ms |
2548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2548 KB |
Output is correct |
2 |
Correct |
2 ms |
2548 KB |
Output is correct |
3 |
Correct |
2 ms |
2548 KB |
Output is correct |
4 |
Correct |
2 ms |
2548 KB |
Output is correct |
5 |
Correct |
2 ms |
2548 KB |
Output is correct |
6 |
Correct |
2 ms |
2548 KB |
Output is correct |
7 |
Correct |
2 ms |
2548 KB |
Output is correct |
8 |
Correct |
2 ms |
2548 KB |
Output is correct |
9 |
Correct |
2 ms |
2548 KB |
Output is correct |
10 |
Correct |
2 ms |
2548 KB |
Output is correct |
11 |
Correct |
3 ms |
2548 KB |
Output is correct |
12 |
Correct |
3 ms |
2548 KB |
Output is correct |
13 |
Correct |
3 ms |
2548 KB |
Output is correct |
14 |
Correct |
3 ms |
2548 KB |
Output is correct |
15 |
Correct |
3 ms |
2548 KB |
Output is correct |
16 |
Correct |
21 ms |
2548 KB |
Output is correct |
17 |
Correct |
21 ms |
2548 KB |
Output is correct |
18 |
Correct |
21 ms |
2548 KB |
Output is correct |
19 |
Correct |
21 ms |
2548 KB |
Output is correct |
20 |
Correct |
10 ms |
2548 KB |
Output is correct |
21 |
Correct |
78 ms |
2548 KB |
Output is correct |
22 |
Correct |
75 ms |
2548 KB |
Output is correct |
23 |
Correct |
76 ms |
2800 KB |
Output is correct |
24 |
Correct |
79 ms |
2800 KB |
Output is correct |
25 |
Correct |
76 ms |
3584 KB |
Output is correct |
26 |
Correct |
78 ms |
3584 KB |
Output is correct |
27 |
Correct |
77 ms |
3584 KB |
Output is correct |
28 |
Correct |
75 ms |
3584 KB |
Output is correct |
29 |
Correct |
80 ms |
3584 KB |
Output is correct |
30 |
Correct |
38 ms |
3584 KB |
Output is correct |
31 |
Correct |
2 ms |
3584 KB |
Output is correct |
32 |
Correct |
2 ms |
3584 KB |
Output is correct |