#include "gap.h"
#include <set>
using namespace std;
long long findGap(int t, int n){
set <long long> 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 <long long>::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 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
11 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
12 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
13 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
14 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Incorrect |
23 ms |
1664 KB |
Output isn't correct |
17 |
Incorrect |
28 ms |
1656 KB |
Output isn't correct |
18 |
Incorrect |
24 ms |
1656 KB |
Output isn't correct |
19 |
Incorrect |
22 ms |
1664 KB |
Output isn't correct |
20 |
Incorrect |
16 ms |
1664 KB |
Output isn't correct |
21 |
Incorrect |
79 ms |
5752 KB |
Output isn't correct |
22 |
Incorrect |
88 ms |
5752 KB |
Output isn't correct |
23 |
Incorrect |
89 ms |
5752 KB |
Output isn't correct |
24 |
Incorrect |
91 ms |
5880 KB |
Output isn't correct |
25 |
Correct |
77 ms |
5808 KB |
Output is correct |
26 |
Incorrect |
77 ms |
5880 KB |
Output isn't correct |
27 |
Incorrect |
82 ms |
5884 KB |
Output isn't correct |
28 |
Incorrect |
86 ms |
5880 KB |
Output isn't correct |
29 |
Incorrect |
88 ms |
5876 KB |
Output isn't correct |
30 |
Incorrect |
80 ms |
5792 KB |
Output isn't correct |
31 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
32 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
5 |
Partially correct |
2 ms |
384 KB |
Partially correct |
6 |
Incorrect |
2 ms |
384 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 |
3 ms |
384 KB |
Output isn't correct |
11 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
12 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
13 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
14 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
15 |
Partially correct |
3 ms |
384 KB |
Partially correct |
16 |
Incorrect |
22 ms |
1664 KB |
Output isn't correct |
17 |
Incorrect |
23 ms |
1664 KB |
Output isn't correct |
18 |
Incorrect |
23 ms |
1664 KB |
Output isn't correct |
19 |
Incorrect |
24 ms |
1656 KB |
Output isn't correct |
20 |
Incorrect |
17 ms |
1664 KB |
Output isn't correct |
21 |
Incorrect |
95 ms |
5764 KB |
Output isn't correct |
22 |
Incorrect |
91 ms |
5808 KB |
Output isn't correct |
23 |
Incorrect |
91 ms |
5844 KB |
Output isn't correct |
24 |
Incorrect |
89 ms |
5752 KB |
Output isn't correct |
25 |
Incorrect |
76 ms |
5752 KB |
Expected int32, but "2500100000" found |
26 |
Incorrect |
94 ms |
5764 KB |
Output isn't correct |
27 |
Incorrect |
91 ms |
5876 KB |
Output isn't correct |
28 |
Incorrect |
86 ms |
5880 KB |
Output isn't correct |
29 |
Incorrect |
93 ms |
5812 KB |
Output isn't correct |
30 |
Incorrect |
78 ms |
5816 KB |
Expected int32, but "2500100000" found |
31 |
Runtime error |
3 ms |
384 KB |
Execution failed because the return code was nonzero |
32 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |