This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "gap.h"
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll inf = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5 + 1;
//void MinMax(long long s, long long t, long long *mn, long long *mx)
//{
//int lo = 1, hi = N, left = N+1, right = 0;
//while (lo <= hi){
//int mid = (lo+hi)>>1;
//if (A[mid] >= s) hi = mid - 1, left = mid;
//else lo = mid + 1;
//}
//lo = 1, hi = N;
//while (lo <= hi){
//int mid = (lo+hi)>>1;
//if (A[mid] <= t) lo = mid + 1, right = mid;
//else hi = mid - 1;
//}
//if (left > right) *mn = *mx = -1;
//else{
//*mn = A[left];
//*mx = A[right];
//}
//}
long long findGap(int t, int n){
ll l = 0, r = inf;
if(t == 1){
ll a[n];
int xl = 0, xr = n - 1;
while(xl <= xr){
MinMax(l, r, &l, &r);
a[xl] = l, a[xr] = r;
l++, r--;
xl++, xr--;
}
ll ret = 1;
for(int i = 1; i < n; i++){
ret = max(ret, a[i] - a[i - 1]);
}
return ret;
}
MinMax(0, inf, &l, &r);
ll x = l + 1, bf = l;
ll ret = (r - l + n - 2) / (n - 1);
while(x < r){
ll mn = -1, mx = -1;
while(mn == -1){
MinMax(x, x + ret, &mn, &mx);
if(mn == -1)x = x + ret + 1;
}
ret = max(ret, mn - bf);
bf = mx;
x = bf + 1;
}
return ret;
}
//int main(){
//cin >> N >> N;
//for(int i = 1; i <= N; i++){
//cin >> A[i];
//}
//cout << findGap(N, N);
//return 0;
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |