Submission #61080

#TimeUsernameProblemLanguageResultExecution timeMemory
61080Flugan42Gap (APIO16_gap)C++14
30 / 100
79 ms2240 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double lld;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define per(i,a,b) for(ll i = a; i >= b; i--)
#define inf 1000000000000000000
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define trav(a,x) for(auto a : x)

long long findGap(int T, int N)
{
	if (T == 1){
		vi a; a.assign(N,0);
		MinMax(0,inf,&a[0],&a[N-1]);
		ll f=1,l=N-2;
		while (f<=l){
			MinMax(a[f-1]+1,a[l+1]-1,&a[f],&a[l]);
			f++; l--;
		}
		ll best = 0;
		rep(i,1,N) if (a[i]-a[i-1] > best) best = a[i]-a[i-1];
		return best;
	} else {
		return 0;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...