이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const int mxN = 1e5+1;
const ll oo = 1e18;
long long findGap(int T, int N)
{
ll amax,amin;
MinMax(0,oo,&amin,&amax);
ll ans = (amax-amin+N-2) / (N-1);
// invariant: low contains a value, range [low+1, low+ans] can't contain answer
ll low = amin+1;
vector<pl> groups = {{amin,amin}};
while(low<amax) {
ll l,r; MinMax(low,min(amax-1,low+ans),&l,&r);
low += ans+1;
if(l==-1) {
continue;
}
groups.push_back({l,r});
}
groups.push_back({amax,amax});
for(int i=1;i<(int)groups.size();++i) {
ans = max(ans, groups[i].first - groups[i-1].second);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |