Submission #1366278

#TimeUsernameProblemLanguageResultExecution timeMemory
1366278vahagngGap (APIO16_gap)C++20
0 / 100
32 ms7044 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

long long findGap(int T, int N){
	long long mn = 0, mx = 1e18;
	set<long long> st;
	long long pre = 0, prepre = 1e18;
	for(int i = 0; i < N / 2; i++){
		MinMax(pre + 1, prepre - 1, &mn, &mx);
		st.insert(mn);
		st.insert(mx);
		// cerr << mn << ' ' << mx << endl;
		pre = mn;
		prepre = mx;
	}
	if(N & 1){
		MinMax(mn, mx, &mn, &mx);
		st.insert(mn);
	}
	vector<long long> a;
	for(auto i : st) a.push_back(i);
	// for(auto i : a) cerr << i << ' ';
	cerr << endl;
	long long res = 0;
	for(int i = 1; i < N; i++){
		if(res < a[i] - a[i - 1]){
			res = a[i] - a[i - 1];
		}
	}
	return res;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...