# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112060 | Eug1ena | Gap (APIO16_gap) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;
void MinMax(lint s, lint t, lint &mn, lint &mx){
cout << s << " " << t << endl;
lint a, b;
cin >> a >> b;
mn = a, mx = b;
}
lint findGap(int T, int N){
if(T == 1){
vector<lint> left{-INF}, right{INF + 100};
while(left.back() + 2 <= right.back()){
lint l, r;
MinMax(left.back() + 1, right.back() - 1, l, r);
if(l == -1){
break;
}
left.push_back(l);
right.push_back(r);
}
vector<lint> a;
for(int i = 1; i < left.size(); i++){
a.push_back(left[i]);
}
for(int i = int(right.size()) - 1; i >= 1; i--){
a.push_back(right[i]);
}
lint ans = 0;
for(int i = 1; i < a.size(); i++){
ans = max(ans, a[i] - a[i - 1]);
}
return ans;
}else{
return -1;
}
}
int main(){
cout << findGap(1, 6) << endl; // 2, 4, 5, 7, 12, 16
}