Submission #1133226

#TimeUsernameProblemLanguageResultExecution timeMemory
1133226Math4Life2020Gap (APIO16_gap)C++20
0 / 100
45 ms2240 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<ll,ll>;

ll findGap(int T, int N) {
	if (T==1) {
		vector<ll> v1;
		ll x=0; ll y=1e18; ll a=-1; ll b=-1;
		while (x <= y) {
			MinMax(x,y,&a,&b);
			if (a==-1) {
				break;
			}
			if (a==b) {
				v1.push_back(a);
			} else {
				v1.push_back(a);
				v1.push_back(b);
			}
			x=a+1; y=b-1;
		}
		sort(v1.begin(),v1.end());
		assert(v1.size()==N);
		ll ans = 0;
		for (ll i=0;i<(N-1);i++) {
			ans = max(ans,v1[i+1]-v1[i]);
		}
		return ans;
	}
}

Compilation message (stderr)

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...