Submission #1234063

#TimeUsernameProblemLanguageResultExecution timeMemory
1234063MalixA Light Inconvenience (CEOI23_light)C++20
100 / 100
167 ms436 KiB
#include "light.h"
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> ti;
typedef vector<ll> li;
typedef vector<li> lii;
 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define LSOne(s) ((s)&(-s))
#define all(x) (x).begin(),(x).end()
 
ll INF=1000000000000000010;
int inf=1e9+10;
ll M=1e9+7;

ll n=1;
vector<ll> a(1,1);

void prepare(){}

std::pair<long long, std::vector<long long>> join(long long p){
	vector<ll> b;
	n+=p;
	ll pos=n;
	b.PB(pos);
	while(pos>1){
		ll k=n-pos+1;
		ll x=max(1LL,pos-k-1);
		auto it=lower_bound(all(a),x);
		if(it!=a.end()&&*it==x)b.PB(x);
		else{
			ll y=*it;
			it--;
			ll z=*it;
			if(z+p>=x)b.PB(x);
			else{
				b.PB(y);
				x=y;
			}
		}
		pos=x;
	}
	reverse(all(b));
	a=b;
	return {p,a};
}

std::pair<long long, std::vector<long long>> leave(long long p){
	vector<ll> b;
	n-=p;
	while(a.back()>n)a.pop_back();
	ll pos=n;
	b.PB(pos);
	while(pos>1){
		ll k=n-pos+1;
		ll x=max(1LL,pos-k-1);
		auto it=lower_bound(all(a),x);
		if(it!=a.end()&&*it==x)b.PB(x);
		else{
			ll y=*it;
			it--;
			ll z=*it;
			if(z+p>=x)b.PB(x);
			else{
				b.PB(y);
				x=y;
			}
		}
		pos=x;
	}
	reverse(all(b));
	a=b;
	return {p,a};
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...