#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a; i<int(b); i++)
long long findGap(int T, int N)
{
if (T==1) {
vector<long long> vals;
long long hi=1e18;
long long lo=0;
long long ans1,ans2;
rep (i,0,(N+1)/2) {
assert(lo<=hi);
MinMax(lo,hi,&ans1,&ans2);
vals.push_back(ans1);
vals.push_back(ans2);
lo=ans1+1;
hi=ans2-1;
}
sort(vals.begin(),vals.end());
long long maxdist=0;
rep (i,0,vals.size()) {
maxdist=max(maxdist,vals[i+1]-vals[i]);
//cout << maxdist << endl;
}
return maxdist;
}
if (T==2) {
vector<long long> vals;
long long hi,lo;
MinMax(0,1e18,&lo,&hi);
//Vi har nu max och min för alla tal.
long long expdist=(hi-lo)/(N-1);
vals.push_back(hi);
vals.push_back(lo);
rep (i,0,N-1) {
long long start,stop;
start=lo+1+(i*(hi-lo))/(N-1);
stop=lo+((i+1)*(hi-lo))/(N-1);
long long ans1,ans2;
MinMax(start,stop,&ans1,&ans2);
if (ans1!=-1) vals.push_back(ans1);
if (ans2!=-1) vals.push_back(ans2);
}
sort(vals.begin(),vals.end());
long long maxdist=0;
rep (i,0,vals.size()) maxdist=max(maxdist,vals[i+1]-vals[i]);
assert(maxdist>=expdist);
return maxdist;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
392 KB |
Output is correct |
4 |
Correct |
3 ms |
392 KB |
Output is correct |
5 |
Correct |
3 ms |
468 KB |
Output is correct |
6 |
Correct |
3 ms |
544 KB |
Output is correct |
7 |
Correct |
3 ms |
544 KB |
Output is correct |
8 |
Correct |
3 ms |
544 KB |
Output is correct |
9 |
Correct |
3 ms |
544 KB |
Output is correct |
10 |
Correct |
3 ms |
544 KB |
Output is correct |
11 |
Correct |
4 ms |
544 KB |
Output is correct |
12 |
Correct |
4 ms |
620 KB |
Output is correct |
13 |
Correct |
3 ms |
620 KB |
Output is correct |
14 |
Correct |
4 ms |
620 KB |
Output is correct |
15 |
Correct |
4 ms |
620 KB |
Output is correct |
16 |
Correct |
23 ms |
1104 KB |
Output is correct |
17 |
Correct |
26 ms |
1124 KB |
Output is correct |
18 |
Correct |
17 ms |
1124 KB |
Output is correct |
19 |
Correct |
17 ms |
1124 KB |
Output is correct |
20 |
Correct |
20 ms |
1124 KB |
Output is correct |
21 |
Correct |
89 ms |
2628 KB |
Output is correct |
22 |
Correct |
88 ms |
2628 KB |
Output is correct |
23 |
Correct |
76 ms |
2628 KB |
Output is correct |
24 |
Correct |
75 ms |
2628 KB |
Output is correct |
25 |
Correct |
65 ms |
2628 KB |
Output is correct |
26 |
Correct |
70 ms |
2628 KB |
Output is correct |
27 |
Correct |
83 ms |
2628 KB |
Output is correct |
28 |
Correct |
93 ms |
2628 KB |
Output is correct |
29 |
Correct |
68 ms |
2628 KB |
Output is correct |
30 |
Correct |
57 ms |
2696 KB |
Output is correct |
31 |
Correct |
3 ms |
2696 KB |
Output is correct |
32 |
Correct |
2 ms |
2696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2696 KB |
Output is correct |
2 |
Runtime error |
3 ms |
2696 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
2 ms |
2696 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
3 ms |
2696 KB |
Execution failed because the return code was nonzero |
5 |
Correct |
3 ms |
2696 KB |
Output is correct |
6 |
Runtime error |
2 ms |
2696 KB |
Execution failed because the return code was nonzero |
7 |
Runtime error |
2 ms |
2696 KB |
Execution failed because the return code was nonzero |
8 |
Runtime error |
2 ms |
2696 KB |
Execution failed because the return code was nonzero |
9 |
Runtime error |
3 ms |
2696 KB |
Execution failed because the return code was nonzero |
10 |
Correct |
3 ms |
2696 KB |
Output is correct |
11 |
Runtime error |
4 ms |
2696 KB |
Execution failed because the return code was nonzero |
12 |
Runtime error |
3 ms |
2696 KB |
Execution failed because the return code was nonzero |
13 |
Runtime error |
3 ms |
2696 KB |
Execution failed because the return code was nonzero |
14 |
Runtime error |
3 ms |
2696 KB |
Execution failed because the return code was nonzero |
15 |
Correct |
4 ms |
2696 KB |
Output is correct |
16 |
Runtime error |
14 ms |
2696 KB |
Execution failed because the return code was nonzero |
17 |
Runtime error |
9 ms |
2696 KB |
Execution failed because the return code was nonzero |
18 |
Runtime error |
12 ms |
2696 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
10 ms |
2696 KB |
Execution failed because the return code was nonzero |
20 |
Correct |
15 ms |
2696 KB |
Output is correct |
21 |
Runtime error |
44 ms |
2696 KB |
Execution failed because the return code was nonzero |
22 |
Runtime error |
33 ms |
2696 KB |
Execution failed because the return code was nonzero |
23 |
Runtime error |
39 ms |
2696 KB |
Execution failed because the return code was nonzero |
24 |
Runtime error |
33 ms |
2696 KB |
Execution failed because the return code was nonzero |
25 |
Correct |
85 ms |
3716 KB |
Output is correct |
26 |
Runtime error |
43 ms |
3716 KB |
Execution failed because the return code was nonzero |
27 |
Runtime error |
38 ms |
3716 KB |
Execution failed because the return code was nonzero |
28 |
Runtime error |
35 ms |
3716 KB |
Execution failed because the return code was nonzero |
29 |
Runtime error |
34 ms |
3716 KB |
Execution failed because the return code was nonzero |
30 |
Correct |
55 ms |
3716 KB |
Output is correct |
31 |
Runtime error |
2 ms |
3716 KB |
Execution failed because the return code was nonzero |
32 |
Runtime error |
3 ms |
3716 KB |
Execution failed because the return code was nonzero |