# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
229989 |
2020-05-07T13:35:24 Z |
kshitij_sodani |
Gap (APIO16_gap) |
C++17 |
|
77 ms |
3308 KB |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long llo;
#define mp make_pair
#define a first
#define b second
#define pb push_back
#include "gap.h"
/*void MinMax(llo aa,llo bb,llo &cc,llo &dd){
cout<<aa<<" "<<bb<<endl;
llo x,y;
cin>>x>>y;
cc=x;
dd=y;
}*/
llo findGap(int t,int n){
if(t==2){
llo low,high;
MinMax(0,1e18,&low,&high);
// cout<<0<<" "<<(llo)1e18<<endl;
// cin>>low>>high;
llo di=(high-low)/((llo)(n-1));
if((high-low)%(n-1)>0){
di+=1;
}
vector<llo> ans;
ans.pb(low);
ans.pb(high);
for(llo i=low+1;i<=high;i+=di){
llo ss,tt;
MinMax(i,i+di-1,&ss,&tt);
// cout<<i<<" "<<i+di-1<<endl;
// cin>>ss>>tt;
if(ss==-1 or tt==-1){
continue;
}
ans.pb(ss);
ans.pb(tt);
}
llo ans2=0;
sort(ans.begin(),ans.end());
for(llo i=0;i<ans.size()-1;i++){
ans2=max(ans2,ans[i+1]-ans[i]);
}
return ans2;
}
else{
llo mi=0;
llo lo=1e18;
llo aa[n];
for(int i=0;i<(n+1)/2;i++){
llo ss,tt;
MinMax(mi,lo,&ss,&tt);
mi=ss+1;
lo=tt-1;
aa[i]=ss;
aa[n-i-1]=tt;
}
llo ans=0;
for(int i=0;i<n-1;i++){
ans=max(ans,aa[i+1]-aa[i]);
}
return ans;
}
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout<<findGap(2,4)<<endl;
return 0;
}*/
Compilation message
gap.cpp: In function 'llo findGap(int, int)':
gap.cpp:44:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(llo i=0;i<ans.size()-1;i++){
~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
17 ms |
768 KB |
Output is correct |
17 |
Correct |
16 ms |
768 KB |
Output is correct |
18 |
Correct |
16 ms |
768 KB |
Output is correct |
19 |
Correct |
16 ms |
768 KB |
Output is correct |
20 |
Correct |
14 ms |
768 KB |
Output is correct |
21 |
Correct |
54 ms |
1900 KB |
Output is correct |
22 |
Correct |
53 ms |
1912 KB |
Output is correct |
23 |
Correct |
53 ms |
1912 KB |
Output is correct |
24 |
Correct |
53 ms |
1912 KB |
Output is correct |
25 |
Correct |
46 ms |
1912 KB |
Output is correct |
26 |
Correct |
61 ms |
1912 KB |
Output is correct |
27 |
Correct |
53 ms |
1912 KB |
Output is correct |
28 |
Correct |
56 ms |
2040 KB |
Output is correct |
29 |
Correct |
52 ms |
1896 KB |
Output is correct |
30 |
Correct |
43 ms |
1916 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
21 ms |
888 KB |
Output is correct |
17 |
Correct |
22 ms |
896 KB |
Output is correct |
18 |
Correct |
22 ms |
896 KB |
Output is correct |
19 |
Correct |
24 ms |
1024 KB |
Output is correct |
20 |
Correct |
12 ms |
512 KB |
Output is correct |
21 |
Correct |
76 ms |
2316 KB |
Output is correct |
22 |
Correct |
77 ms |
2288 KB |
Output is correct |
23 |
Correct |
73 ms |
2216 KB |
Output is correct |
24 |
Correct |
73 ms |
2272 KB |
Output is correct |
25 |
Correct |
72 ms |
3308 KB |
Output is correct |
26 |
Correct |
77 ms |
2288 KB |
Output is correct |
27 |
Correct |
75 ms |
2272 KB |
Output is correct |
28 |
Correct |
74 ms |
2288 KB |
Output is correct |
29 |
Correct |
74 ms |
2268 KB |
Output is correct |
30 |
Correct |
46 ms |
1452 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |