#include "gap.h"
#include <bits/stdc++.h>
#define endl "\n"
using namespace std ;
typedef long long ll;
typedef long double ld ;
const int N=2e7;
const ll inf=1e18 ;
const ll mod = 1e9 + 7 ;
ll mypower(ll x, ll y){
if(y == 0) return 1 ;
if(y == 1) return x ;
ll ret = mypower(x , y / 2);
ret = (ret * ret) % mod;
if(y % 2) ret = ( ret * x ) % mod ;
return ret ;
}
map < ll , ll > mp ;
vector < ll > v ;
long long findGap(int T, int N)
{
ll n = N ;
ll mn = -1 , mx = 1e18 ;
if(T == 1){
ll l = -1 , r = 1e18 + 1 ;
while(v.size() != N){
MinMax(l , r , &mn , &mx) ;
if(mn == -1 && mx == -1){
break ;
}
if(mp.count(mn) == 0){
mp[mn] = 1 ;
v.push_back(mn) ;
l = mn + 1 ;
}
if(mp.count(mx) == 0){
mp[mx] = 1 ;
v.push_back(mx) ;
r = mx - 1;
}
}
sort(v.begin() , v.end()) ;
ll ans = 0 ;
for(int i = 1 ; i < N ; i++){
ans = max(ans , v[i] - v[i - 1]) ;
}
return ans ;
}
else{
MinMax(mn , mx , &mn , &mx) ;
ll len = (mx - mn + 1) / (n - 1) ;
ll q = mn ;
ll ans = 0 ;
ll la = mx ;
for(int i = mn ; i < la ; i+= len){
MinMax(i , i + len , &mn , &mx) ;
if(mn != -1){
ans = max(ans , mn - q) ;
q = mx ;
}
}
return ans ;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:26:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
26 | while(v.size() != N){
| ~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
17 ms |
2252 KB |
Output is correct |
17 |
Correct |
17 ms |
2204 KB |
Output is correct |
18 |
Correct |
17 ms |
2252 KB |
Output is correct |
19 |
Correct |
17 ms |
2252 KB |
Output is correct |
20 |
Correct |
16 ms |
2248 KB |
Output is correct |
21 |
Correct |
76 ms |
8092 KB |
Output is correct |
22 |
Correct |
76 ms |
8056 KB |
Output is correct |
23 |
Correct |
75 ms |
8104 KB |
Output is correct |
24 |
Correct |
85 ms |
8016 KB |
Output is correct |
25 |
Correct |
72 ms |
8040 KB |
Output is correct |
26 |
Correct |
77 ms |
8088 KB |
Output is correct |
27 |
Correct |
78 ms |
8048 KB |
Output is correct |
28 |
Correct |
75 ms |
8248 KB |
Output is correct |
29 |
Correct |
77 ms |
8020 KB |
Output is correct |
30 |
Correct |
69 ms |
8048 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3074 ms |
208 KB |
Time limit exceeded |
2 |
Execution timed out |
3069 ms |
208 KB |
Time limit exceeded |
3 |
Execution timed out |
3077 ms |
208 KB |
Time limit exceeded |
4 |
Execution timed out |
3071 ms |
208 KB |
Time limit exceeded |
5 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
6 |
Execution timed out |
3044 ms |
208 KB |
Time limit exceeded |
7 |
Execution timed out |
3041 ms |
208 KB |
Time limit exceeded |
8 |
Execution timed out |
3071 ms |
208 KB |
Time limit exceeded |
9 |
Execution timed out |
3077 ms |
208 KB |
Time limit exceeded |
10 |
Partially correct |
1 ms |
208 KB |
Partially correct |
11 |
Execution timed out |
3068 ms |
208 KB |
Time limit exceeded |
12 |
Execution timed out |
3078 ms |
208 KB |
Time limit exceeded |
13 |
Execution timed out |
3064 ms |
208 KB |
Time limit exceeded |
14 |
Execution timed out |
3068 ms |
208 KB |
Time limit exceeded |
15 |
Execution timed out |
3079 ms |
208 KB |
Time limit exceeded |
16 |
Execution timed out |
3073 ms |
464 KB |
Time limit exceeded |
17 |
Execution timed out |
3071 ms |
464 KB |
Time limit exceeded |
18 |
Execution timed out |
3067 ms |
464 KB |
Time limit exceeded |
19 |
Execution timed out |
3064 ms |
488 KB |
Time limit exceeded |
20 |
Partially correct |
7 ms |
464 KB |
Partially correct |
21 |
Execution timed out |
3052 ms |
1064 KB |
Time limit exceeded |
22 |
Execution timed out |
3052 ms |
1060 KB |
Time limit exceeded |
23 |
Execution timed out |
3044 ms |
1060 KB |
Time limit exceeded |
24 |
Execution timed out |
3041 ms |
968 KB |
Time limit exceeded |
25 |
Execution timed out |
3073 ms |
1048 KB |
Time limit exceeded |
26 |
Execution timed out |
3043 ms |
968 KB |
Time limit exceeded |
27 |
Execution timed out |
3037 ms |
1052 KB |
Time limit exceeded |
28 |
Execution timed out |
3033 ms |
1004 KB |
Time limit exceeded |
29 |
Execution timed out |
3042 ms |
976 KB |
Time limit exceeded |
30 |
Partially correct |
30 ms |
976 KB |
Partially correct |
31 |
Execution timed out |
3086 ms |
208 KB |
Time limit exceeded |
32 |
Execution timed out |
3075 ms |
208 KB |
Time limit exceeded |