# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
520361 |
2022-01-29T16:09:56 Z |
krit3379 |
Gap (APIO16_gap) |
C++17 |
|
65 ms |
3216 KB |
#include<bits/stdc++.h>
using namespace std;
#include "gap.h"
long long a[100005],l,r,ans,ma,mi;
long long findGap(int t,int n){
int i,j;
if(t==1){
l=0,r=1e18;
for(i=1,j=n;i<=j;i++,j--){
MinMax(l,r,&mi,&ma);
a[i]=mi;
a[j]=ma;
l=mi+1;
r=ma-1;
}
for(i=1;i<n;i++)ans=max(ans,a[i+1]-a[i]);
return ans;
}
else{
long long last,gap;
vector<long long> a;
l=0,r=1e18;
MinMax(l,r,&mi,&ma);
a.push_back(mi);
a.push_back(ma);
last=ma-1;
gap=(ma-mi+n-2)/(n-1);
while(l<r){
l=mi+1;
r=min(mi+gap,last);
MinMax(l,r,&mi,&ma);
if(mi==-1){
mi=r;
if(r==last)break;
continue;
}
a.push_back(mi);
a.push_back(ma);
mi=r;
if(r==last)break;
}
sort(a.begin(),a.end());
for(i=1;i<a.size();i++)ans=max(ans,a[i]-a[i-1]);
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(i=1;i<a.size();i++)ans=max(ans,a[i]-a[i-1]);
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
10 ms |
684 KB |
Output is correct |
17 |
Correct |
10 ms |
584 KB |
Output is correct |
18 |
Correct |
11 ms |
704 KB |
Output is correct |
19 |
Correct |
12 ms |
636 KB |
Output is correct |
20 |
Correct |
8 ms |
712 KB |
Output is correct |
21 |
Correct |
44 ms |
1728 KB |
Output is correct |
22 |
Correct |
52 ms |
1748 KB |
Output is correct |
23 |
Correct |
42 ms |
1856 KB |
Output is correct |
24 |
Correct |
44 ms |
1824 KB |
Output is correct |
25 |
Correct |
33 ms |
1824 KB |
Output is correct |
26 |
Correct |
36 ms |
1868 KB |
Output is correct |
27 |
Correct |
44 ms |
1836 KB |
Output is correct |
28 |
Correct |
41 ms |
1732 KB |
Output is correct |
29 |
Correct |
38 ms |
1744 KB |
Output is correct |
30 |
Correct |
35 ms |
1876 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
17 ms |
860 KB |
Output is correct |
17 |
Correct |
15 ms |
808 KB |
Output is correct |
18 |
Correct |
14 ms |
840 KB |
Output is correct |
19 |
Correct |
13 ms |
884 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
53 ms |
2216 KB |
Output is correct |
22 |
Correct |
65 ms |
2228 KB |
Output is correct |
23 |
Correct |
53 ms |
2156 KB |
Output is correct |
24 |
Correct |
50 ms |
2248 KB |
Output is correct |
25 |
Correct |
61 ms |
3216 KB |
Output is correct |
26 |
Correct |
56 ms |
2172 KB |
Output is correct |
27 |
Correct |
63 ms |
2232 KB |
Output is correct |
28 |
Correct |
53 ms |
2216 KB |
Output is correct |
29 |
Correct |
54 ms |
2188 KB |
Output is correct |
30 |
Correct |
33 ms |
1472 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |