This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "light.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
vector<ll> a;
void prepare(){
	n = 1;
	a.push_back(1);
}
vector<ll> rev(vector<ll> v){
	reverse(v.begin(), v.end());
	return v;
}
std::pair<long long, std::vector<long long>> join(long long p){
	n += p;
	for (auto &x:a) x += p;
	while(true){
		ll t = a.back() - 1 - (n - a.back() + 1);
		if (t <= 1) break;
		a.push_back(t);
	}
	a.push_back(1);
	return {p, rev(a)};
}
std::pair<long long, std::vector<long long>> leave(long long p){
	n -= p;
	vector<ll> b;
	for (auto &x:a) if (x <= n) b.push_back(x);
	a.clear();
	a.push_back(n);
	
	while(true){
		ll t = a.back() - 1 - (n - a.back() + 1);
		if (t <= 1) break;
		ll mn = 4e18;
		for (auto &x:b) if (x + p >= t) mn = min(mn, max(t, x));
		assert(mn < a.back());
		a.push_back(mn);
	}
	a.push_back(1);
	return {p, rev(a)};
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |