#include "gap.h"
#include <set>
using namespace std;
long long findGap(int t, int n){
set <int> numbers;
long long m, M;
if(t==1){
m=0;
M=1000000000000000000;
while(true){
if(numbers.size()==n)
break;
MinMax(m, M, &m, &M);
if(m==-1)
break;
numbers.insert(m);
if(m==M)
break;
numbers.insert(M);
m++;M--;
}
}else if(t==2){
for(int i = 0;i < n>>1;i ++){
m=(long double)i*1e18/(n>>1);
if(i==(n>>1)-1)
M=1000000000000000000;
else
M=(long double)(i+1)*1e18/(n>>1);
while(true){
if(numbers.size()==n)
break;
MinMax(m, M, &m, &M);
if(m==-1)
break;
numbers.insert(m);
if(m==M)
break;
numbers.insert(M);
m++;M--;
}
}
}
m=1000000000000000000;
set <int>::iterator it=numbers.begin();
M=*it;
it++;
while(it!=numbers.end()){
m=min(m, *it-M);
M=*it;
it++;
}
return m;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(numbers.size()==n)
~~~~~~~~~~~~~~^~~
gap.cpp:31:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(numbers.size()==n)
~~~~~~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
392 KB |
Output isn't correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
11 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
12 |
Incorrect |
4 ms |
416 KB |
Output isn't correct |
13 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
14 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Incorrect |
26 ms |
2168 KB |
Output isn't correct |
17 |
Incorrect |
27 ms |
2176 KB |
Output isn't correct |
18 |
Incorrect |
30 ms |
2172 KB |
Output isn't correct |
19 |
Incorrect |
26 ms |
2176 KB |
Output isn't correct |
20 |
Incorrect |
18 ms |
1892 KB |
Output isn't correct |
21 |
Incorrect |
143 ms |
7672 KB |
Output isn't correct |
22 |
Incorrect |
175 ms |
7672 KB |
Output isn't correct |
23 |
Incorrect |
147 ms |
7620 KB |
Output isn't correct |
24 |
Incorrect |
191 ms |
7672 KB |
Output isn't correct |
25 |
Incorrect |
118 ms |
7032 KB |
Output isn't correct |
26 |
Incorrect |
162 ms |
7624 KB |
Output isn't correct |
27 |
Incorrect |
188 ms |
7604 KB |
Output isn't correct |
28 |
Incorrect |
182 ms |
7672 KB |
Output isn't correct |
29 |
Incorrect |
200 ms |
7900 KB |
Output isn't correct |
30 |
Incorrect |
69 ms |
6648 KB |
Output isn't correct |
31 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
32 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
8 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
5 |
Partially correct |
3 ms |
384 KB |
Partially correct |
6 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
10 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
11 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
12 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
13 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
14 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
15 |
Partially correct |
2 ms |
512 KB |
Partially correct |
16 |
Incorrect |
33 ms |
2176 KB |
Output isn't correct |
17 |
Incorrect |
39 ms |
2144 KB |
Output isn't correct |
18 |
Incorrect |
31 ms |
2168 KB |
Output isn't correct |
19 |
Incorrect |
33 ms |
2172 KB |
Output isn't correct |
20 |
Incorrect |
18 ms |
1920 KB |
Output isn't correct |
21 |
Incorrect |
184 ms |
7672 KB |
Output isn't correct |
22 |
Incorrect |
191 ms |
7668 KB |
Output isn't correct |
23 |
Incorrect |
175 ms |
7816 KB |
Output isn't correct |
24 |
Incorrect |
181 ms |
7808 KB |
Output isn't correct |
25 |
Incorrect |
78 ms |
7032 KB |
Expected int32, but "2500100000" found |
26 |
Incorrect |
158 ms |
7716 KB |
Output isn't correct |
27 |
Incorrect |
175 ms |
7672 KB |
Output isn't correct |
28 |
Incorrect |
166 ms |
7672 KB |
Output isn't correct |
29 |
Incorrect |
164 ms |
7672 KB |
Output isn't correct |
30 |
Incorrect |
74 ms |
6520 KB |
Expected int32, but "2500100000" found |
31 |
Runtime error |
1 ms |
256 KB |
Execution failed because the return code was nonzero |
32 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |