#include "gap.h"
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;
ll const inf = 1000000000000000000;
long long findGap(int T, int N)
{
vector<ll> v;
if(T == 1){
long long* from = new long long(0);
long long* to = new long long(inf);
for(int i = 0;i < N; i += 2){
MinMax(*from, *to, from, to);
if(-1 == *from)
continue;
v.push_back(*from);
v.push_back(*to);
*from = *from + 1;
*to = *to - 1;
}
} else {
long long* from = new long long(0);
long long* to = new long long(inf);
MinMax(*from, *to, from, to); /// 1 + N
ll d = (*to - *from) / (N - 1);
v.push_back(*from);
v.push_back(*to);
*from = *from + 1;
*to = *to - 1;
while(*from <= *to){
long long* a = new long long(0);
long long* b = new long long(0);
MinMax(*from, *from + d, a, b);
if(0 <= *a){
v.push_back(*a);
v.push_back(*b);
}
*from = *from + d + 1;
}
}
sort(v.begin(), v.end());
ll result = 0;
for(int i = 1; i < v.size(); i++)
result = max(result, v[i] - v[i - 1]);
return result;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:55:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i < v.size(); i++)
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
304 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
292 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
7 ms |
384 KB |
Output is correct |
14 |
Correct |
7 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
19 ms |
896 KB |
Output is correct |
17 |
Correct |
19 ms |
896 KB |
Output is correct |
18 |
Correct |
21 ms |
896 KB |
Output is correct |
19 |
Correct |
18 ms |
896 KB |
Output is correct |
20 |
Correct |
25 ms |
896 KB |
Output is correct |
21 |
Correct |
59 ms |
2288 KB |
Output is correct |
22 |
Correct |
59 ms |
2292 KB |
Output is correct |
23 |
Correct |
63 ms |
2292 KB |
Output is correct |
24 |
Correct |
59 ms |
2292 KB |
Output is correct |
25 |
Correct |
52 ms |
2288 KB |
Output is correct |
26 |
Correct |
60 ms |
2292 KB |
Output is correct |
27 |
Correct |
62 ms |
2236 KB |
Output is correct |
28 |
Correct |
59 ms |
2288 KB |
Output is correct |
29 |
Correct |
68 ms |
2288 KB |
Output is correct |
30 |
Correct |
66 ms |
2288 KB |
Output is correct |
31 |
Correct |
4 ms |
308 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
512 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
7 ms |
512 KB |
Output is correct |
14 |
Correct |
7 ms |
512 KB |
Output is correct |
15 |
Correct |
5 ms |
512 KB |
Output is correct |
16 |
Correct |
22 ms |
2304 KB |
Output is correct |
17 |
Correct |
22 ms |
2304 KB |
Output is correct |
18 |
Correct |
39 ms |
2292 KB |
Output is correct |
19 |
Correct |
27 ms |
2300 KB |
Output is correct |
20 |
Correct |
13 ms |
2048 KB |
Output is correct |
21 |
Correct |
86 ms |
8428 KB |
Output is correct |
22 |
Correct |
83 ms |
8340 KB |
Output is correct |
23 |
Correct |
81 ms |
8356 KB |
Output is correct |
24 |
Correct |
79 ms |
8304 KB |
Output is correct |
25 |
Correct |
88 ms |
8936 KB |
Output is correct |
26 |
Correct |
80 ms |
8308 KB |
Output is correct |
27 |
Correct |
80 ms |
8404 KB |
Output is correct |
28 |
Correct |
83 ms |
8360 KB |
Output is correct |
29 |
Correct |
80 ms |
8424 KB |
Output is correct |
30 |
Correct |
44 ms |
7416 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
6 ms |
384 KB |
Output is correct |