# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
107819 |
2019-04-25T22:09:59 Z |
Noam527 |
Gap (APIO16_gap) |
C++17 |
|
106 ms |
3344 KB |
#include <bits/stdc++.h>
#define CHECK cout << "ok" << endl
#define finish(x) return cout << x << endl, 0
typedef long long ll;
typedef long double ldb;
const int md = 1e9 + 7;
const ll inf = 1e18;
const int OO = 1;
const int OOO = 1;
using namespace std;
void MinMax(ll s, ll t, ll *mn, ll *mx);
ll findGap(int t, int n) {
ll lo, hi, a, b;
MinMax(0, inf, &lo, &hi);
if (t == 2) {
vector<ll> pos;
ll d = (hi - lo) / (n - 1);
pos.push_back(lo);
for (ll i = lo + 1; i < hi; i += d + 1) {
MinMax(i, min(hi - 1, i + d), &a, &b);
if (a != -1) {
pos.push_back(a);
pos.push_back(b);
}
}
pos.push_back(hi);
ll rtn = pos[1] - pos[0];
for (int i = 2; i < pos.size(); i++)
rtn = max(rtn, pos[i] - pos[i - 1]);
return rtn;
}
vector<ll> pos = { lo, hi };
int left = n - 2;
while (left > 0) {
MinMax(lo + 1, hi - 1, &lo, &hi);
pos.push_back(lo);
pos.push_back(hi);
left -= 2;
}
sort(pos.begin(), pos.end());
ll rtn = pos[1] - pos[0];
for (int i = 2; i < pos.size(); i++)
rtn = max(rtn, pos[i] - pos[i - 1]);
return rtn;
}
/*
int main() {
ll ans = findGap(0, 4);
cout << "my ans " << ans << '\n';
}
*/
Compilation message
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:30:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 2; i < pos.size(); i++)
~~^~~~~~~~~~~~
gap.cpp:44:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 2; i < pos.size(); i++)
~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
432 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
16 ms |
896 KB |
Output is correct |
17 |
Correct |
17 ms |
1024 KB |
Output is correct |
18 |
Correct |
16 ms |
1024 KB |
Output is correct |
19 |
Correct |
15 ms |
896 KB |
Output is correct |
20 |
Correct |
11 ms |
896 KB |
Output is correct |
21 |
Correct |
56 ms |
2316 KB |
Output is correct |
22 |
Correct |
61 ms |
2260 KB |
Output is correct |
23 |
Correct |
56 ms |
2288 KB |
Output is correct |
24 |
Correct |
62 ms |
2288 KB |
Output is correct |
25 |
Correct |
50 ms |
2288 KB |
Output is correct |
26 |
Correct |
55 ms |
2360 KB |
Output is correct |
27 |
Correct |
54 ms |
2288 KB |
Output is correct |
28 |
Correct |
53 ms |
2288 KB |
Output is correct |
29 |
Correct |
68 ms |
2288 KB |
Output is correct |
30 |
Correct |
46 ms |
2308 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
25 ms |
972 KB |
Output is correct |
17 |
Correct |
25 ms |
868 KB |
Output is correct |
18 |
Correct |
21 ms |
996 KB |
Output is correct |
19 |
Correct |
18 ms |
896 KB |
Output is correct |
20 |
Correct |
9 ms |
512 KB |
Output is correct |
21 |
Correct |
66 ms |
2288 KB |
Output is correct |
22 |
Correct |
70 ms |
2472 KB |
Output is correct |
23 |
Correct |
64 ms |
2316 KB |
Output is correct |
24 |
Correct |
73 ms |
2288 KB |
Output is correct |
25 |
Correct |
75 ms |
3344 KB |
Output is correct |
26 |
Correct |
73 ms |
2268 KB |
Output is correct |
27 |
Correct |
66 ms |
2288 KB |
Output is correct |
28 |
Correct |
65 ms |
2260 KB |
Output is correct |
29 |
Correct |
106 ms |
2316 KB |
Output is correct |
30 |
Correct |
35 ms |
1528 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |