# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
548128 |
2022-04-12T13:52:58 Z |
joshjms |
Gap (APIO16_gap) |
C++14 |
|
68 ms |
2272 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << #x << " => " << x << "\n";
ll t, n, ans;
ll l, r, mn, mx, x;
vector <ll> vect;
ll T1() {
l = 0, r = 1e18;
while(vect.size() < n) {
MinMax(l, r, &mn, &mx);
vect.pb(mn);
if(mn != mx) vect.pb(mx);
l = mn + 1;
r = mx - 1;
}
sort(vect.begin(), vect.end());
for(int i = 0; i < vect.size() - 1; i++)
ans = max(ans, vect[i + 1] - vect[i]);
return ans;
}
ll T2() {
MinMax(0, 1e18, &l, &r);
x = (r - l + n) / (n - 1);
for(; l <= r; l += x) {
MinMax(l, l + x - 1, &mn, &mx);
if(mn != -1) vect.pb(mn);
if(mn != mx && mx != -1) vect.pb(mx);
}
sort(vect.begin(), vect.end());
for(int i = 0; i < vect.size() - 1; i++)
ans = max(ans, vect[i + 1] - vect[i]);
return ans;
}
ll findGap(int T, int N) {
t = T, n = N;
if(t == 1) return T1();
else return T2();
}
Compilation message
gap.cpp: In function 'long long int T1()':
gap.cpp:19:23: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
19 | while(vect.size() < n) {
| ~~~~~~~~~~~~^~~
gap.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i = 0; i < vect.size() - 1; i++)
| ~~^~~~~~~~~~~~~~~~~
gap.cpp:27:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
27 | for(int i = 0; i < vect.size() - 1; i++)
| ^~~
gap.cpp:29:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
29 | return ans;
| ^~~~~~
gap.cpp: In function 'long long int T2()':
gap.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0; i < vect.size() - 1; i++)
| ~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 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 |
316 KB |
Output is correct |
13 |
Correct |
1 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 |
14 ms |
848 KB |
Output is correct |
17 |
Correct |
15 ms |
852 KB |
Output is correct |
18 |
Correct |
11 ms |
812 KB |
Output is correct |
19 |
Correct |
11 ms |
856 KB |
Output is correct |
20 |
Correct |
11 ms |
848 KB |
Output is correct |
21 |
Correct |
42 ms |
2272 KB |
Output is correct |
22 |
Correct |
42 ms |
2240 KB |
Output is correct |
23 |
Correct |
43 ms |
2236 KB |
Output is correct |
24 |
Correct |
53 ms |
2204 KB |
Output is correct |
25 |
Correct |
43 ms |
2236 KB |
Output is correct |
26 |
Correct |
47 ms |
2204 KB |
Output is correct |
27 |
Correct |
47 ms |
2176 KB |
Output is correct |
28 |
Correct |
49 ms |
2192 KB |
Output is correct |
29 |
Correct |
49 ms |
2248 KB |
Output is correct |
30 |
Correct |
33 ms |
2204 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
256 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 |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 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 |
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 |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
13 ms |
848 KB |
Output is correct |
17 |
Correct |
18 ms |
888 KB |
Output is correct |
18 |
Correct |
16 ms |
912 KB |
Output is correct |
19 |
Correct |
14 ms |
908 KB |
Output is correct |
20 |
Correct |
7 ms |
540 KB |
Output is correct |
21 |
Correct |
53 ms |
2212 KB |
Output is correct |
22 |
Correct |
60 ms |
2204 KB |
Output is correct |
23 |
Correct |
54 ms |
2240 KB |
Output is correct |
24 |
Correct |
68 ms |
2200 KB |
Output is correct |
25 |
Correct |
53 ms |
2220 KB |
Output is correct |
26 |
Correct |
54 ms |
2188 KB |
Output is correct |
27 |
Correct |
56 ms |
2228 KB |
Output is correct |
28 |
Correct |
66 ms |
2244 KB |
Output is correct |
29 |
Correct |
65 ms |
2120 KB |
Output is correct |
30 |
Correct |
29 ms |
1448 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |