# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624439 | socpite | Gap (APIO16_gap) | C++14 | 62 ms | 3220 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"
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
ll ans = 0;
int n;
void solve(ll l, ll r){
if(r-l <= ans)return;
//cout << l << " " << r << endl;
ll dist = (r-l+n)/n;
vector<pair<ll, ll>> A;
for(ll i = l; i <= r; i+=dist){
pair<ll, ll> tmp;
MinMax(i, min(i+dist-1, r), &tmp.f, &tmp.s);
if(tmp.s > 0){
A.push_back(tmp);
}
}
for(int i = 1; i < A.size(); i++){
if(A[i-1].f != -1 && A[i].f != -1)ans = max(ans, A[i].f - A[i-1].s);
}
for(auto v: A)solve(v.f, v.s);
}
long long findGap(int T, int N)
{
n = N;
solve(0, 1e18);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |