#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long mn = 0, mx = 0;
set<long long> st;
long long findGap(int T, int N)
{
long long ans = 1;
if (T == 2 && N >= 4)
{
MinMax(0, 1e18, &mn, &mx);
long long left = mn;
long long l = mn + 1, r = mx - 1;
long long ans = 1;
long long last = mn;
if (mx - mn == N - 1)
return 1;
if (mx - mn == N)
return 2;
for (int i = 0; i < N; i++)
{
int nxt = l + (r - left) / N - 1 + (i >= N - (r - left) % N && (r - left) % N);
MinMax(l, nxt, &mn, &mx);
l = nxt + 1;
if (mn != -1)
{
ans = max(ans, mn - last);
last = mx;
}
}
ans = max(ans, r - last + 1);
return ans;
}
else
{
long long l = 0, r = 1e18;
while (1)
{
MinMax(l, r, &mn, &mx);
if (mn == -1)
break;
st.insert(mn);
st.insert(mx);
l = mn + 1, r = mx - 1;
if (mn == mx || (long long)st.size() >= N)
break;
}
}
long long last = *st.begin();
for (auto &i : st)
ans = max(ans, i - last), last = i;
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
15 ms |
1676 KB |
Output is correct |
17 |
Correct |
12 ms |
1624 KB |
Output is correct |
18 |
Correct |
11 ms |
1772 KB |
Output is correct |
19 |
Correct |
9 ms |
1624 KB |
Output is correct |
20 |
Correct |
8 ms |
1772 KB |
Output is correct |
21 |
Correct |
45 ms |
5716 KB |
Output is correct |
22 |
Correct |
43 ms |
5656 KB |
Output is correct |
23 |
Correct |
44 ms |
5772 KB |
Output is correct |
24 |
Correct |
45 ms |
5712 KB |
Output is correct |
25 |
Correct |
40 ms |
5712 KB |
Output is correct |
26 |
Correct |
49 ms |
5712 KB |
Output is correct |
27 |
Correct |
42 ms |
5712 KB |
Output is correct |
28 |
Correct |
40 ms |
5712 KB |
Output is correct |
29 |
Correct |
41 ms |
5712 KB |
Output is correct |
30 |
Correct |
35 ms |
5712 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Runtime error |
1 ms |
344 KB |
Execution failed because the return code was nonzero |
7 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
8 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
9 |
Runtime error |
1 ms |
344 KB |
Execution failed because the return code was nonzero |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
12 |
Runtime error |
1 ms |
344 KB |
Execution failed because the return code was nonzero |
13 |
Runtime error |
1 ms |
344 KB |
Execution failed because the return code was nonzero |
14 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
15 |
Runtime error |
1 ms |
344 KB |
Execution failed because the return code was nonzero |
16 |
Runtime error |
4 ms |
600 KB |
Execution failed because the return code was nonzero |
17 |
Runtime error |
4 ms |
600 KB |
Execution failed because the return code was nonzero |
18 |
Runtime error |
4 ms |
600 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
3 ms |
600 KB |
Execution failed because the return code was nonzero |
20 |
Correct |
5 ms |
600 KB |
Output is correct |
21 |
Runtime error |
23 ms |
1156 KB |
Execution failed because the return code was nonzero |
22 |
Runtime error |
18 ms |
1112 KB |
Execution failed because the return code was nonzero |
23 |
Runtime error |
18 ms |
1112 KB |
Execution failed because the return code was nonzero |
24 |
Runtime error |
12 ms |
1112 KB |
Execution failed because the return code was nonzero |
25 |
Runtime error |
11 ms |
1204 KB |
Execution failed because the return code was nonzero |
26 |
Runtime error |
12 ms |
1112 KB |
Execution failed because the return code was nonzero |
27 |
Runtime error |
12 ms |
1192 KB |
Execution failed because the return code was nonzero |
28 |
Runtime error |
13 ms |
1112 KB |
Execution failed because the return code was nonzero |
29 |
Runtime error |
12 ms |
1112 KB |
Execution failed because the return code was nonzero |
30 |
Correct |
21 ms |
1112 KB |
Output is correct |
31 |
Runtime error |
1 ms |
344 KB |
Execution failed because the return code was nonzero |
32 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |