Submission #1241061

#TimeUsernameProblemLanguageResultExecution timeMemory
1241061thelegendary08Gap (APIO16_gap)C++17
30 / 100
28 ms1864 KiB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
long long findGap(int T, int N)
{
	if(T == 1){
		long long L = -1; long long R = 1000000000000000005; 
		long long mn, mx;
		vector<long long>v(N);
		int l = 0; int r = N-1;
		while(l <= r){
			// cout<<L+1<<' '<<R-1<<'\n';
			MinMax(L+1, R-1, &mn, &mx);
			L = mn; R = mx;
			// cout<<L<<' '<<R<<'\n';
			if(L == R){
				v[l] = L;
			}
			else{
				v[l] = mn; v[r] = mx;
			}
			l++; r--;
		}
		// for(auto u : v)cout<<u<<' ';
		// cout<<'\n';
		long long ans = 0;
		for(int i = 0; i<N-1; i++){
			if(ans < v[i+1] - v[i])ans = v[i+1] - v[i];
		}
		return ans;
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...