# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1014727 | idioti11 | Library (JOI18_library) | C++17 | 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;
int query(int a, int b) {
cout << "? " << a << " " << b << endl;
int result;
cin >> result;
return result;
}
int main() {
int n;
cin >> n;
vector<int> sizes(n + 1, 0);
int l = 1, r = n;
while (l < r) {
int mid = (l + r) / 2;
int max1 = query(l, mid);
int max2 = query(mid + 1, r);
if (max1 < max2) {
l = mid + 1;
} else {
r = mid;
}
}
cout << "! " << l << endl;
return 0;
}