# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
35169 |
2017-11-18T14:26:46 Z |
cheater2k |
Gap (APIO16_gap) |
C++14 |
|
89 ms |
8304 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
vector<long long> a;
long long s = 0, t = 2e18;
long long mn, mx;
long long solve1() {
for (int i = 1; i <= (n + 1) / 2; ++i) {
if (s <= t) MinMax(s, t, &mn, &mx);
a.push_back(mn);
a.push_back(mx);
s = mn + 1, t = mx - 1;
}
}
long long solve2() {
MinMax(0, 2e18, &s, &t);
long long gap = (t - s + n - 2) / (n - 1);
for (long long i = s; i <= t; i += gap + 1) {
MinMax(i, i + gap, &mn, &mx);
a.push_back(mn);
a.push_back(mx);
}
}
long long findGap(int T, int _N) {
n = _N;
if (T == 1) solve1();
else solve2();
long long ans = 0;
sort(a.begin(), a.end());
for (int i = 0; i < a.size()-1; ++i) {
ans = max(ans, a[i+1] - a[i]);
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int solve1()':
gap.cpp:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
gap.cpp: In function 'long long int solve2()':
gap.cpp:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:37:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < a.size()-1; ++i) {
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5144 KB |
Output is correct |
2 |
Correct |
0 ms |
5144 KB |
Output is correct |
3 |
Correct |
0 ms |
5144 KB |
Output is correct |
4 |
Correct |
0 ms |
5144 KB |
Output is correct |
5 |
Correct |
0 ms |
5144 KB |
Output is correct |
6 |
Correct |
0 ms |
5144 KB |
Output is correct |
7 |
Correct |
0 ms |
5144 KB |
Output is correct |
8 |
Correct |
0 ms |
5144 KB |
Output is correct |
9 |
Correct |
0 ms |
5144 KB |
Output is correct |
10 |
Correct |
0 ms |
5144 KB |
Output is correct |
11 |
Correct |
0 ms |
5144 KB |
Output is correct |
12 |
Correct |
0 ms |
5144 KB |
Output is correct |
13 |
Correct |
0 ms |
5144 KB |
Output is correct |
14 |
Correct |
0 ms |
5144 KB |
Output is correct |
15 |
Correct |
0 ms |
5144 KB |
Output is correct |
16 |
Correct |
13 ms |
5616 KB |
Output is correct |
17 |
Correct |
13 ms |
5616 KB |
Output is correct |
18 |
Correct |
9 ms |
5616 KB |
Output is correct |
19 |
Correct |
13 ms |
5616 KB |
Output is correct |
20 |
Correct |
9 ms |
5616 KB |
Output is correct |
21 |
Correct |
63 ms |
6768 KB |
Output is correct |
22 |
Correct |
69 ms |
6768 KB |
Output is correct |
23 |
Correct |
53 ms |
6768 KB |
Output is correct |
24 |
Correct |
69 ms |
6768 KB |
Output is correct |
25 |
Correct |
53 ms |
6768 KB |
Output is correct |
26 |
Correct |
56 ms |
6768 KB |
Output is correct |
27 |
Correct |
56 ms |
6768 KB |
Output is correct |
28 |
Correct |
59 ms |
6768 KB |
Output is correct |
29 |
Correct |
59 ms |
6768 KB |
Output is correct |
30 |
Correct |
36 ms |
6768 KB |
Output is correct |
31 |
Correct |
0 ms |
5144 KB |
Output is correct |
32 |
Correct |
0 ms |
5144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5144 KB |
Output is correct |
2 |
Correct |
0 ms |
5144 KB |
Output is correct |
3 |
Correct |
0 ms |
5144 KB |
Output is correct |
4 |
Correct |
0 ms |
5144 KB |
Output is correct |
5 |
Correct |
0 ms |
5144 KB |
Output is correct |
6 |
Correct |
0 ms |
5144 KB |
Output is correct |
7 |
Correct |
0 ms |
5144 KB |
Output is correct |
8 |
Correct |
0 ms |
5144 KB |
Output is correct |
9 |
Correct |
0 ms |
5144 KB |
Output is correct |
10 |
Correct |
0 ms |
5144 KB |
Output is correct |
11 |
Correct |
0 ms |
5288 KB |
Output is correct |
12 |
Correct |
0 ms |
5288 KB |
Output is correct |
13 |
Correct |
0 ms |
5288 KB |
Output is correct |
14 |
Correct |
0 ms |
5288 KB |
Output is correct |
15 |
Correct |
0 ms |
5288 KB |
Output is correct |
16 |
Correct |
23 ms |
6000 KB |
Output is correct |
17 |
Correct |
19 ms |
6000 KB |
Output is correct |
18 |
Correct |
19 ms |
6000 KB |
Output is correct |
19 |
Correct |
23 ms |
6000 KB |
Output is correct |
20 |
Correct |
6 ms |
6000 KB |
Output is correct |
21 |
Correct |
83 ms |
8304 KB |
Output is correct |
22 |
Correct |
76 ms |
8304 KB |
Output is correct |
23 |
Correct |
79 ms |
8304 KB |
Output is correct |
24 |
Correct |
69 ms |
8304 KB |
Output is correct |
25 |
Correct |
76 ms |
8304 KB |
Output is correct |
26 |
Correct |
79 ms |
8304 KB |
Output is correct |
27 |
Correct |
86 ms |
8304 KB |
Output is correct |
28 |
Correct |
86 ms |
8304 KB |
Output is correct |
29 |
Correct |
89 ms |
8304 KB |
Output is correct |
30 |
Correct |
39 ms |
8304 KB |
Output is correct |
31 |
Correct |
0 ms |
5144 KB |
Output is correct |
32 |
Correct |
0 ms |
5144 KB |
Output is correct |