| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 897127 | raul2008487 | Gap (APIO16_gap) | C++17 | 37 ms | 4212 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>
#include "gap.h"
#define ll long long
#define pll pair<ll,ll>
#define vl vector<ll>
#define pb push_back
#define in insert
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
long long findGap(int T, int N)
{
ll l, r, i, j, lo = 1, hi = 1000000000000000000, ans = 0, n = N;
MinMax(lo, hi, &l, &r);
if( T == 1 ){
vl v;
v.pb(l);
v.pb(r);
while(l != r && v.size() < n){
lo = l + 1, hi = r - 1;
MinMax(lo, hi, &l, &r);
v.pb(l);
v.pb(r);
}
sort(all(v));
for(i = 1; i<n; i++){
ans = max(ans, (v[i] - v[i-1]));
}
return ans;
}
ll a, b, d1, d2, pw = 1;
while(l != r){
a = b = -1;
while(a == -1){MinMax(l + 1, l + 1 + pw, &a, &b); pw <<= 1;}
ans = max(ans, (a - l));
pw = ans;
l = b;
}
return ans;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
