#include <bits/stdc++.h>
#include "gap.h"
#define INF 1'000'000'000'000'000'000ll
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
LL ans, C;
LL Min, Max;
vector<LL> V;
long long findGap(int T, int N){
if (T == 1){
LL l=0, r=INF;
for (int i=0; i<N; i+=2){
LL x, y;
MinMax(l, r, &x, &y);
V.push_back(x);
V.push_back(y);
l=x+1, r=y-1;
}
}
else{
MinMax(0, INF, &Min, &Max);
ans = C = (Max-Min+N-1)/N;
LL t = Min;
V.push_back(Min);
while (t+C <= Max){
LL x, y;
MinMax(t+1, min(t+C, Max-1), &x, &y);
if (x>=0) V.push_back(x);
if (y>=0) V.push_back(y);
t += C;
}
V.push_back(Max);
}
sort(V.begin(), V.end());
for (int i=0; i<V.size()-1; i++) ans = max(ans, V[i+1]-V[i]);
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<V.size()-1; i++) ans = max(ans, V[i+1]-V[i]);
~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
17 ms |
1400 KB |
Output is correct |
17 |
Correct |
17 ms |
1400 KB |
Output is correct |
18 |
Correct |
18 ms |
1400 KB |
Output is correct |
19 |
Correct |
17 ms |
1400 KB |
Output is correct |
20 |
Correct |
14 ms |
1148 KB |
Output is correct |
21 |
Correct |
61 ms |
4080 KB |
Output is correct |
22 |
Correct |
61 ms |
4080 KB |
Output is correct |
23 |
Correct |
61 ms |
4188 KB |
Output is correct |
24 |
Correct |
61 ms |
4208 KB |
Output is correct |
25 |
Correct |
52 ms |
3440 KB |
Output is correct |
26 |
Correct |
60 ms |
4080 KB |
Output is correct |
27 |
Correct |
61 ms |
4208 KB |
Output is correct |
28 |
Correct |
63 ms |
4172 KB |
Output is correct |
29 |
Correct |
60 ms |
4180 KB |
Output is correct |
30 |
Correct |
46 ms |
3056 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 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 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
21 ms |
1440 KB |
Output is correct |
17 |
Correct |
20 ms |
1404 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 |
4076 KB |
Output is correct |
22 |
Correct |
78 ms |
4112 KB |
Output is correct |
23 |
Correct |
77 ms |
4072 KB |
Output is correct |
24 |
Correct |
77 ms |
4080 KB |
Output is correct |
25 |
Correct |
75 ms |
4492 KB |
Output is correct |
26 |
Correct |
78 ms |
4072 KB |
Output is correct |
27 |
Correct |
77 ms |
4124 KB |
Output is correct |
28 |
Correct |
77 ms |
4080 KB |
Output is correct |
29 |
Correct |
77 ms |
4080 KB |
Output is correct |
30 |
Correct |
39 ms |
2172 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |