CSES - APIO 2016 - Results
Submission details
Task:Gap
Sender:ArktinenKarpalo
Submission time:2019-04-14 03:09:24 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'long long int findGap(int, int)':
input/code.cpp:18:19: error: 'n' was not declared in this scope
   for(int i=0; i<(n+1)/2; i++) {
                   ^
input/code.cpp:26:7: warning: unused variable 'ed' [-Wunused-variable]
    ll ed = mx;
       ^~
input/code.cpp:31:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1; i<qq.size(); i++)
                ~^~~~~~~~~~

Code

#include <bits/stdc++.h>
#include "gap.h"
#define ll long long
#define ull unsigned long long
#define ld long double
#define M 1000000007
#define P complex<long long>
#define X real()
#define Y imag()

using namespace std;

ll findGap(int T, int N) {
	if(T == 1) {
		ll ans = 0;
		ll s=0, t=1e18, mn, mx;
		vector<ll> qq;
		for(int i=0; i<(n+1)/2; i++) {
			MinMax(s, t, &mn, &mx);
			if(mn == -1)
				break;
			qq.push_back(mn);
			qq.push_back(mx);
			t = mx-1;
			s = mn+1;
			ll ed = mx;
			if(t<s)
				break;
		}
		sort(qq.begin(), qq.end());
		for(int i=1; i<qq.size(); i++)
			ans = max(ans, qq[i]-qq[i-1]);
		return ans;
	} else {
		return -1;
	}
}