#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int t, int n)
{
if(t == 1)
{
vector<long long> l, r;
long long st=0, dr=1e18;
while(n)
{
MinMax(st, dr, &st, &dr);
if(st == dr)
{
l.push_back(st);
break;
n--;
}
l.push_back(st);
r.push_back(dr);
st++;
dr--;
n-=2;
}
while(!r.empty())
{
l.push_back(r.back());
r.pop_back();
}
long long ans=0;
for(int i=1;i<(int)l.size();i++)
ans=max(ans, l[i] - l[i-1]);
return ans;
}
else
{
long long st, dr;
MinMax(0, 1e18, &st, &dr);
long long x = (dr-st + n-2) / (n-1);
vector<long long> v;
v.push_back(st);
st++;
while(st < dr)
{
long long a, b;
MinMax(st, st+x-1, &a, &b);
if(a != -1)
{
v.push_back(a);
v.push_back(b);
}
st+=x;
}
if(v.back() != dr)
v.push_back(dr);
long long ans=x;
for(int i=1;i<(int)v.size();i++)
ans=max(ans, v[i] - v[i-1]);
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
948 KB |
Output is correct |
17 |
Correct |
9 ms |
988 KB |
Output is correct |
18 |
Correct |
12 ms |
980 KB |
Output is correct |
19 |
Correct |
10 ms |
936 KB |
Output is correct |
20 |
Correct |
9 ms |
972 KB |
Output is correct |
21 |
Correct |
42 ms |
2628 KB |
Output is correct |
22 |
Correct |
43 ms |
2584 KB |
Output is correct |
23 |
Correct |
43 ms |
2636 KB |
Output is correct |
24 |
Correct |
40 ms |
2564 KB |
Output is correct |
25 |
Correct |
35 ms |
2544 KB |
Output is correct |
26 |
Correct |
45 ms |
2540 KB |
Output is correct |
27 |
Correct |
44 ms |
2576 KB |
Output is correct |
28 |
Correct |
39 ms |
2636 KB |
Output is correct |
29 |
Correct |
44 ms |
2640 KB |
Output is correct |
30 |
Correct |
41 ms |
2632 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
2 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
13 ms |
864 KB |
Output is correct |
17 |
Correct |
13 ms |
900 KB |
Output is correct |
18 |
Correct |
17 ms |
848 KB |
Output is correct |
19 |
Correct |
14 ms |
880 KB |
Output is correct |
20 |
Correct |
6 ms |
476 KB |
Output is correct |
21 |
Correct |
61 ms |
2212 KB |
Output is correct |
22 |
Correct |
59 ms |
2192 KB |
Output is correct |
23 |
Correct |
59 ms |
2176 KB |
Output is correct |
24 |
Correct |
56 ms |
2152 KB |
Output is correct |
25 |
Correct |
50 ms |
3260 KB |
Output is correct |
26 |
Correct |
69 ms |
2156 KB |
Output is correct |
27 |
Correct |
67 ms |
2236 KB |
Output is correct |
28 |
Correct |
57 ms |
2200 KB |
Output is correct |
29 |
Correct |
59 ms |
2372 KB |
Output is correct |
30 |
Correct |
30 ms |
1444 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |