# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
390925 | Blagojce | Gap (APIO16_gap) | C++11 | 0 ms | 0 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>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int mxn = 1e5;
#include "gap.h"
/*
int n;
ll A[mxn];
void MinMax(ll s, ll t, ll &mn, ll &mx){
mn = -1;
mx = -1;
fr(i, 0, n){
if(A[i] >= s){
if(A[i] <= t) mn = A[i];
break;
}
}
for(int i = n-1; i >= 0; i --){
if(A[i] <= t){
if(A[i] >= s) mx = A[i];
break;
}
}
}
*/
long long findGap(int T, int N)
{
ll a1, an;
MinMax(0, 1e18, a1, an);
ll d = (an - a1)/(N-1);
ll pr = a1;
ll ans = 0;
for(int i = 0; i*d <= an; i++){
ll ai, aj;
MinMax(i*d, min((i+1)*d, an), ai, aj);
if(ai != -1){
ans = max(ans, ai-pr);
pr = aj;
}
}
return ans;
}
/*
int main(){
cin >> n;
fr(i, 0, n) cin >> A[i];
cout<<findGap(2, n)<<endl;
}*/