# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
284895 |
2020-08-28T07:49:29 Z |
triplem5ds |
Gap (APIO16_gap) |
C++14 |
|
93 ms |
3312 KB |
#include "gap.h"
#include "bits/stdc++.h"
using namespace std;
long long findGap(int T, int N)
{
long long ans = 0;
long long mn, mx;
if(T == 1){
vector<long long> L, R;
long long LO = 0, HI = 1000000000000000000;
while(L.size() + R.size() < N){
MinMax(LO,HI, & mn, & mx);
L.push_back(mn);
R.push_back(mx);
LO = mn + 1;
HI = mx - 1;
}
reverse(R.begin(),R.end());
if(N & 1)
L.pop_back();
vector<long long> v;
for(auto x : L)v.push_back(x);
for(auto x : R)v.push_back(x);
for(int i = 1; i < v.size(); i++)
ans = max(ans, v[i] - v[i-1]);
} else {
MinMax(0, 1000000000000000000, &mn, &mx);
long long d = (mx - mn + N - 3) / (N - 1);
vector<long long> v({mn, mx});
long long cur = mn + 1;
while(cur < v[1]) {
MinMax(cur, min(v[1] - 1, cur + d - 1), &mn, &mx);
cur += d;
if(mn == -1)continue;
v.push_back(mn);
v.push_back(mx);
}
sort(v.begin(),v.end());
for(int i = 1; i < v.size(); i++)
ans = max(ans, v[i] - v[i-1]);
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:31: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
12 | while(L.size() + R.size() < N){
| ~~~~~~~~~~~~~~~~~~~~^~~
gap.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i = 1; i < v.size(); i++)
| ~~^~~~~~~~~~
gap.cpp:55:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i = 1; i < v.size(); i++)
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
14 ms |
1216 KB |
Output is correct |
17 |
Correct |
13 ms |
1216 KB |
Output is correct |
18 |
Correct |
14 ms |
1208 KB |
Output is correct |
19 |
Correct |
13 ms |
1260 KB |
Output is correct |
20 |
Correct |
10 ms |
1216 KB |
Output is correct |
21 |
Correct |
54 ms |
3120 KB |
Output is correct |
22 |
Correct |
53 ms |
3028 KB |
Output is correct |
23 |
Correct |
53 ms |
3100 KB |
Output is correct |
24 |
Correct |
56 ms |
3056 KB |
Output is correct |
25 |
Correct |
46 ms |
3100 KB |
Output is correct |
26 |
Correct |
54 ms |
3100 KB |
Output is correct |
27 |
Correct |
54 ms |
3028 KB |
Output is correct |
28 |
Correct |
62 ms |
3100 KB |
Output is correct |
29 |
Correct |
62 ms |
3060 KB |
Output is correct |
30 |
Correct |
45 ms |
3100 KB |
Output is correct |
31 |
Correct |
0 ms |
384 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
19 ms |
892 KB |
Output is correct |
17 |
Correct |
17 ms |
896 KB |
Output is correct |
18 |
Correct |
17 ms |
896 KB |
Output is correct |
19 |
Correct |
17 ms |
896 KB |
Output is correct |
20 |
Correct |
8 ms |
512 KB |
Output is correct |
21 |
Correct |
80 ms |
2288 KB |
Output is correct |
22 |
Correct |
79 ms |
2288 KB |
Output is correct |
23 |
Correct |
73 ms |
2252 KB |
Output is correct |
24 |
Correct |
82 ms |
2288 KB |
Output is correct |
25 |
Correct |
74 ms |
3312 KB |
Output is correct |
26 |
Correct |
93 ms |
2368 KB |
Output is correct |
27 |
Correct |
74 ms |
2292 KB |
Output is correct |
28 |
Correct |
72 ms |
2288 KB |
Output is correct |
29 |
Correct |
82 ms |
2288 KB |
Output is correct |
30 |
Correct |
39 ms |
1536 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
0 ms |
384 KB |
Output is correct |