# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
47956 | | 3zp | Gap (APIO16_gap) | C++14 | | 82 ms | 1532 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 "gap.h"
#define ll long long
#include<bits/stdc++.h>
using namespace std;
long long findGap(int T, int N)
{
ll s, t;
MinMax(0, 1e18, &s, &t);
ll L = t - s;
ll d = (L + N - 2) / (N - 1);
d++;
ll ans = d-1;
ll x = s;
while(x != t){
ll p, q;
if(x + d >= t) break;
MinMax(x + 1, x + d, &p , &q);
if(q != -1) {
ans = max(ans, p - x);
x = q;
continue;
}
ll w = 2;
while(1){
if(x + w*d >= t) {
MinMax(x + 1,t-1,&p , &q);
ans = max(ans, p-x);
return ans;
}
MinMax(x + 1,min( x + w * d, (ll)1e18),&p , &q);
if(q == -1) {w++; continue;}
ans = max(ans, p - x);
x = q;
break;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |