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 "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MX = 1e18;
ll x, y;
vector<ll> p;
void query(ll l, ll r) {
MinMax(l,r,&x,&y);
if (x != -1) p.push_back(x);
if (y != -1) p.push_back(y);
}
ll findGap(int T, int N) {
ll l = 0, r = MX;
if (T == 1) {
for (int i = 1; i <= (N+1)/2 && l <= r; i++) {
query(l,r);
l = x+1, r = y-1;
}
}
else {
query(l,r);
l = x+1, r = y-1;
for (int i = N-1; i > 0; i--) {
ll q = l+(r-l)/i;
query(l,q);
l = q+1;
}
}
sort(p.begin(),p.end());
p.resize(unique(p.begin(),p.end())-p.begin());
ll ans = 0;
for (int i = 1; i < p.size(); i++) {
ans = max(ans,p[i]-p[i-1]);
}
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:38:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for (int i = 1; i < p.size(); i++) {
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |