# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
366221 |
2021-02-13T14:27:22 Z |
mathking1021 |
Gap (APIO16_gap) |
C++17 |
|
67 ms |
3424 KB |
#include "gap.h"
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll t, n;
vector<ll> ve1, ve2, ve;
long long findGap(int T, int N)
{
t = T;
n = N;
if(t == 1)
{
ll ans = 0;
ll a, b;
MinMax(0LL, (ll)2e18, &a, &b);
ve1.push_back(a);
ve2.push_back(b);
for(ll i = 0; i < (n - 1) / 2; i++)
{
ll t1, t2;
MinMax(a + 1, b - 1, &t1, &t2);
ve1.push_back(t1);
ve2.push_back(t2);
a = t1, b = t2;
}
for(ll i = 1; i < ve1.size(); i++) ans = max(ans, ve1[i] - ve1[i - 1]);
for(ll i = 1; i < ve2.size(); i++) ans = max(ans, ve2[i - 1] - ve2[i]);
ans = max(ans, ve2[ve2.size() - 1] - ve1[ve1.size() - 1]);
return ans;
}
else
{
ll a, b;
MinMax(0LL, (ll)2e18, &a, &b);
ll c = (b - a + n - 2) / (n - 1);
ll ans = c;
ve.push_back(a);
for(ll i = a + 1; i <= b - 1; i += c)
{
ll t3 = -1, t4 = -1;
MinMax(i, min(i + c - 1, b - 1), &t3, &t4);
if(t3 != -1)
{
ve.push_back(t3);
ve.push_back(t4);
}
}
ve.push_back(b);
for(ll i = 1; i < ve.size(); i++)
{
ans = max(ans, ve[i] - ve[i - 1]);
}
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:31:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(ll i = 1; i < ve1.size(); i++) ans = max(ans, ve1[i] - ve1[i - 1]);
| ~~^~~~~~~~~~~~
gap.cpp:32:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(ll i = 1; i < ve2.size(); i++) ans = max(ans, ve2[i - 1] - ve2[i]);
| ~~^~~~~~~~~~~~
gap.cpp:54:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(ll i = 1; i < ve.size(); i++)
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
11 ms |
876 KB |
Output is correct |
17 |
Correct |
11 ms |
876 KB |
Output is correct |
18 |
Correct |
11 ms |
1004 KB |
Output is correct |
19 |
Correct |
12 ms |
1004 KB |
Output is correct |
20 |
Correct |
9 ms |
876 KB |
Output is correct |
21 |
Correct |
45 ms |
2072 KB |
Output is correct |
22 |
Correct |
44 ms |
2072 KB |
Output is correct |
23 |
Correct |
45 ms |
2072 KB |
Output is correct |
24 |
Correct |
44 ms |
2128 KB |
Output is correct |
25 |
Correct |
45 ms |
2072 KB |
Output is correct |
26 |
Correct |
43 ms |
2072 KB |
Output is correct |
27 |
Correct |
51 ms |
2072 KB |
Output is correct |
28 |
Correct |
46 ms |
2072 KB |
Output is correct |
29 |
Correct |
43 ms |
2072 KB |
Output is correct |
30 |
Correct |
35 ms |
2072 KB |
Output is correct |
31 |
Correct |
0 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
396 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
15 ms |
876 KB |
Output is correct |
17 |
Correct |
15 ms |
876 KB |
Output is correct |
18 |
Correct |
14 ms |
876 KB |
Output is correct |
19 |
Correct |
16 ms |
876 KB |
Output is correct |
20 |
Correct |
8 ms |
620 KB |
Output is correct |
21 |
Correct |
61 ms |
2316 KB |
Output is correct |
22 |
Correct |
60 ms |
2276 KB |
Output is correct |
23 |
Correct |
63 ms |
2276 KB |
Output is correct |
24 |
Correct |
67 ms |
2276 KB |
Output is correct |
25 |
Correct |
61 ms |
3424 KB |
Output is correct |
26 |
Correct |
61 ms |
2276 KB |
Output is correct |
27 |
Correct |
67 ms |
2276 KB |
Output is correct |
28 |
Correct |
60 ms |
2276 KB |
Output is correct |
29 |
Correct |
67 ms |
2276 KB |
Output is correct |
30 |
Correct |
39 ms |
1516 KB |
Output is correct |
31 |
Correct |
0 ms |
364 KB |
Output is correct |
32 |
Correct |
0 ms |
364 KB |
Output is correct |