#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
#define SZ(v) ((int)(v).size())
using ll = long long;
void MinMax(ll lo, ll up, ll *mn, ll *mx);
ll findGap(int sous_tache, int nb_elem)
{
if (sous_tache == 2)
{
ll smallest, biggest;
MinMax((ll)0, (ll)1e18, &smallest, &biggest);
ll delta = ceil( (long double)(biggest - smallest) / (nb_elem - 1));
vector<ll> sparse_elem;
for (ll k(0); k < nb_elem - 1; ++k)
{
ll l, r;
MinMax(smallest + k * delta, smallest + (k+1) * delta-1, &l, &r);
if (l != -1)
{
sparse_elem.push_back(l);
sparse_elem.push_back(r);
}
}
sparse_elem.push_back(biggest);
ll ans = delta;
for (int i(0); i + 1 < SZ(sparse_elem); ++i)
ans = max(ans, sparse_elem[i+1] - sparse_elem[i]);
return ans;
}
else
{
ll arr[nb_elem];
MinMax(0LL, (ll)1e18, arr, arr + nb_elem - 1);
for (int i(1), j(nb_elem - 2); i <= j; i++, j--)
MinMax(arr[i-1]+1, arr[j+1] - 1, arr + i, arr + j);
ll ans(0);
for (int i(0); i < nb_elem-1; ++i)
ans = max(ans, arr[i+1] - arr[i]);
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
19 ms |
768 KB |
Output is correct |
17 |
Correct |
16 ms |
732 KB |
Output is correct |
18 |
Correct |
18 ms |
768 KB |
Output is correct |
19 |
Correct |
16 ms |
768 KB |
Output is correct |
20 |
Correct |
13 ms |
772 KB |
Output is correct |
21 |
Correct |
62 ms |
1824 KB |
Output is correct |
22 |
Correct |
62 ms |
1912 KB |
Output is correct |
23 |
Correct |
54 ms |
1912 KB |
Output is correct |
24 |
Correct |
54 ms |
1912 KB |
Output is correct |
25 |
Correct |
46 ms |
1888 KB |
Output is correct |
26 |
Correct |
54 ms |
1904 KB |
Output is correct |
27 |
Correct |
54 ms |
1856 KB |
Output is correct |
28 |
Correct |
55 ms |
1912 KB |
Output is correct |
29 |
Correct |
53 ms |
1912 KB |
Output is correct |
30 |
Correct |
40 ms |
1912 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
20 ms |
896 KB |
Output is correct |
17 |
Correct |
20 ms |
896 KB |
Output is correct |
18 |
Correct |
20 ms |
896 KB |
Output is correct |
19 |
Correct |
20 ms |
896 KB |
Output is correct |
20 |
Correct |
12 ms |
512 KB |
Output is correct |
21 |
Correct |
71 ms |
2288 KB |
Output is correct |
22 |
Correct |
71 ms |
2288 KB |
Output is correct |
23 |
Correct |
71 ms |
2264 KB |
Output is correct |
24 |
Correct |
77 ms |
2304 KB |
Output is correct |
25 |
Correct |
65 ms |
3308 KB |
Output is correct |
26 |
Correct |
71 ms |
2312 KB |
Output is correct |
27 |
Correct |
71 ms |
2324 KB |
Output is correct |
28 |
Correct |
74 ms |
2288 KB |
Output is correct |
29 |
Correct |
71 ms |
2288 KB |
Output is correct |
30 |
Correct |
40 ms |
1528 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |