# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1009630 |
2024-06-27T18:01:38 Z |
dpsaveslives |
Gap (APIO16_gap) |
C++17 |
|
46 ms |
3624 KB |
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF = 1e18;
ll findGap(int T, int N){
if(T == 1){
ll l = 1, r = INF;
ll mn, mx;
vector<ll> arr(N);
int ind = 0;
for(int i = 1;i<=(N+1)/2;++i){
MinMax(l,r,&mn,&mx);
arr[ind] = mn;
arr[++ind] = mx;
++ind;
l = mn+1; r = mx-1;
}
sort(arr.begin(),arr.end());
ll ans = 0;
for(int i = 0;i<=arr.size()-1;++i){
ans = max(ans,arr[i+1]-arr[i]);
}
return ans;
}
ll a1, an;
MinMax(1,INF,&a1,&an);
ll k = (an-a1+N-2)/(N-1); //N-1 differences between i and i+1
ll cur = a1,x,y,ans = k, last = a1;
while(cur+k+1 <= an){
MinMax(cur,cur+k,&x,&y);
if(x != -1){
ans = max(ans,x-last);
last = y;
}
cur += k+1;
}
MinMax(cur,an,&x,&y);
if(x != -1){
ans = max(ans,x-last);
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:21:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int i = 0;i<=arr.size()-1;++i){
| ~^~~~~~~~~~~~~~
# |
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 |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
0 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2496 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 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 |
6 ms |
2740 KB |
Output is correct |
17 |
Correct |
6 ms |
2648 KB |
Output is correct |
18 |
Correct |
6 ms |
2648 KB |
Output is correct |
19 |
Correct |
8 ms |
2648 KB |
Output is correct |
20 |
Correct |
5 ms |
2648 KB |
Output is correct |
21 |
Correct |
30 ms |
3416 KB |
Output is correct |
22 |
Correct |
34 ms |
3416 KB |
Output is correct |
23 |
Correct |
27 ms |
3416 KB |
Output is correct |
24 |
Correct |
25 ms |
3416 KB |
Output is correct |
25 |
Correct |
29 ms |
3416 KB |
Output is correct |
26 |
Correct |
26 ms |
3416 KB |
Output is correct |
27 |
Correct |
27 ms |
3416 KB |
Output is correct |
28 |
Correct |
28 ms |
3416 KB |
Output is correct |
29 |
Correct |
28 ms |
3576 KB |
Output is correct |
30 |
Correct |
28 ms |
3624 KB |
Output is correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
0 ms |
2392 KB |
Output is correct |
7 |
Correct |
0 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2488 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 |
7 ms |
2588 KB |
Output is correct |
17 |
Correct |
10 ms |
2392 KB |
Output is correct |
18 |
Correct |
8 ms |
2392 KB |
Output is correct |
19 |
Correct |
8 ms |
2592 KB |
Output is correct |
20 |
Correct |
5 ms |
2392 KB |
Output is correct |
21 |
Correct |
31 ms |
2648 KB |
Output is correct |
22 |
Correct |
30 ms |
2648 KB |
Output is correct |
23 |
Correct |
33 ms |
2648 KB |
Output is correct |
24 |
Correct |
31 ms |
2648 KB |
Output is correct |
25 |
Correct |
30 ms |
2648 KB |
Output is correct |
26 |
Correct |
34 ms |
2828 KB |
Output is correct |
27 |
Correct |
46 ms |
2648 KB |
Output is correct |
28 |
Correct |
45 ms |
2648 KB |
Output is correct |
29 |
Correct |
40 ms |
2648 KB |
Output is correct |
30 |
Correct |
21 ms |
2812 KB |
Output is correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |