# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
218203 |
2020-04-01T13:59:44 Z |
SamAnd |
Gap (APIO16_gap) |
C++17 |
|
82 ms |
4148 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 100005;
const long long M = 1000000000000000000;
int n;
long long a[N];
int h[N];
long long findGap(int T, int N)
{
n = N;
if (T == 1)
{
a[0] = -1;
a[n + 1] = M + 1;
for (int l = 1, r = n; l <= r; ++l, --r)
{
long long minu, maxu;
MinMax(a[l - 1] + 1, a[r + 1] - 1, &minu, &maxu);
a[l] = minu;
a[r] = maxu;
}
long long ans = 0;
for (int i = 1; i < n; ++i)
ans = max(ans, a[i + 1] - a[i]);
return ans;
}
long long minu, maxu;
MinMax(0, M, &minu, &maxu);
if (n == 2)
return maxu - minu;
long long d = maxu - minu - 1;
vector<long long> v;
for (int i = 0; i < n - 2; ++i)
v.push_back(d / (n - 2));
for (int i = 0; i < d % (n - 2); ++i)
++v[i];
vector<pair<long long, long long> > vv;
vv.push_back(m_p(minu, minu));
long long u = minu;
for (int i = 0; i < v.size(); ++i)
{
long long l = u + 1;
long long r = l + v[i] - 1;
long long minu, maxu;
MinMax(l, r, &minu, &maxu);
vv.push_back(m_p(minu, maxu));
u = r;
}
vv.push_back(m_p(maxu, maxu));
for (int i = n - 2; i >= 0; --i)
{
if (vv[i + 1].first != -1)
h[i] = i + 1;
else
h[i] = h[i + 1];
}
long long ans = 0;
for (int i = 0; i < n - 1; ++i)
{
if (vv[i].first == -1)
continue;
ans = max(ans, vv[h[i]].first - vv[i].second);
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:45:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); ++i)
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 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 |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 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 |
16 ms |
768 KB |
Output is correct |
17 |
Correct |
16 ms |
768 KB |
Output is correct |
18 |
Correct |
19 ms |
768 KB |
Output is correct |
19 |
Correct |
16 ms |
768 KB |
Output is correct |
20 |
Correct |
12 ms |
800 KB |
Output is correct |
21 |
Correct |
64 ms |
1912 KB |
Output is correct |
22 |
Correct |
63 ms |
1912 KB |
Output is correct |
23 |
Correct |
53 ms |
1912 KB |
Output is correct |
24 |
Correct |
52 ms |
1888 KB |
Output is correct |
25 |
Correct |
44 ms |
1916 KB |
Output is correct |
26 |
Correct |
52 ms |
1912 KB |
Output is correct |
27 |
Correct |
55 ms |
1912 KB |
Output is correct |
28 |
Correct |
54 ms |
1912 KB |
Output is correct |
29 |
Correct |
56 ms |
2040 KB |
Output is correct |
30 |
Correct |
38 ms |
1912 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 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 |
4 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 |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 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 |
512 KB |
Output is correct |
16 |
Correct |
23 ms |
1404 KB |
Output is correct |
17 |
Correct |
21 ms |
1428 KB |
Output is correct |
18 |
Correct |
23 ms |
1404 KB |
Output is correct |
19 |
Correct |
20 ms |
1404 KB |
Output is correct |
20 |
Correct |
12 ms |
1404 KB |
Output is correct |
21 |
Correct |
71 ms |
4076 KB |
Output is correct |
22 |
Correct |
71 ms |
4148 KB |
Output is correct |
23 |
Correct |
71 ms |
4072 KB |
Output is correct |
24 |
Correct |
76 ms |
4076 KB |
Output is correct |
25 |
Correct |
71 ms |
4076 KB |
Output is correct |
26 |
Correct |
82 ms |
4072 KB |
Output is correct |
27 |
Correct |
71 ms |
4048 KB |
Output is correct |
28 |
Correct |
72 ms |
4080 KB |
Output is correct |
29 |
Correct |
75 ms |
4120 KB |
Output is correct |
30 |
Correct |
40 ms |
4076 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |