# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
933385 |
2024-02-25T15:29:42 Z |
SmuggingSpun |
Gap (APIO16_gap) |
C++14 |
|
45 ms |
3628 KB |
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>void maximize(T& a, T b){
if(a < b){
a = b;
}
}
long long findGap(int T, int n){
if(T == 1){
vector<ll>a(n);
ll ans = 0, low = 0, high = 1e18;
int l = 0, r = n - 1;
while(l <= r){
MinMax(low, high, &a[l], &a[r]);
low = a[l++] + 1;
high = a[r--] - 1;
}
for(int i = 1; i < n; i++){
maximize(ans, a[i] - a[i - 1]);
}
return ans;
}
ll a_1, a_n;
MinMax(0, 1e18, &a_1, &a_n);
ll average = (a_n - a_1 + n - 2) / (n - 1), ans = average;
for(ll i = a_1; i <= a_n; i += average + 1){
ll x, y;
MinMax(i, min(i + average, a_n), &x, &y);
if(x != -1){
maximize(ans, x - a_1);
a_1 = y;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2388 KB |
Output is correct |
16 |
Correct |
8 ms |
2604 KB |
Output is correct |
17 |
Correct |
9 ms |
2592 KB |
Output is correct |
18 |
Correct |
8 ms |
2572 KB |
Output is correct |
19 |
Correct |
8 ms |
2588 KB |
Output is correct |
20 |
Correct |
6 ms |
2572 KB |
Output is correct |
21 |
Correct |
29 ms |
3620 KB |
Output is correct |
22 |
Correct |
29 ms |
3624 KB |
Output is correct |
23 |
Correct |
29 ms |
3628 KB |
Output is correct |
24 |
Correct |
31 ms |
3624 KB |
Output is correct |
25 |
Correct |
27 ms |
3616 KB |
Output is correct |
26 |
Correct |
30 ms |
3624 KB |
Output is correct |
27 |
Correct |
29 ms |
3624 KB |
Output is correct |
28 |
Correct |
32 ms |
3628 KB |
Output is correct |
29 |
Correct |
29 ms |
3624 KB |
Output is correct |
30 |
Correct |
24 ms |
3612 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2388 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
0 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
10 ms |
2752 KB |
Output is correct |
17 |
Correct |
10 ms |
2592 KB |
Output is correct |
18 |
Correct |
10 ms |
2588 KB |
Output is correct |
19 |
Correct |
10 ms |
2656 KB |
Output is correct |
20 |
Correct |
7 ms |
2536 KB |
Output is correct |
21 |
Correct |
40 ms |
2856 KB |
Output is correct |
22 |
Correct |
42 ms |
2852 KB |
Output is correct |
23 |
Correct |
45 ms |
2840 KB |
Output is correct |
24 |
Correct |
41 ms |
2860 KB |
Output is correct |
25 |
Correct |
41 ms |
2848 KB |
Output is correct |
26 |
Correct |
40 ms |
2856 KB |
Output is correct |
27 |
Correct |
40 ms |
3088 KB |
Output is correct |
28 |
Correct |
42 ms |
2856 KB |
Output is correct |
29 |
Correct |
41 ms |
2852 KB |
Output is correct |
30 |
Correct |
22 ms |
2844 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |