#include <bits/stdc++.h>
using namespace std;
#define int long long
namespace {
vector<int> curr = {1};
int N = 1;
void solve(int x){
auto chooselatest = [&](int l,int r){
auto iter = upper_bound(curr.begin(),curr.end(),r);
assert(iter!=curr.begin());
iter--;
int d = min((*iter)+x,r);
assert(l<=d);
return d;
};
vector<int> newcurr = {1};
int currele = 1;
while(currele<N){
int nextele = N+1+currele;
if(nextele&1)nextele++;
nextele/=2;
currele = chooselatest(currele+1,nextele);
newcurr.emplace_back(currele);
}
assert(newcurr.size()<=150);
swap(newcurr,curr);
}
}
void prepare(){}
pair<int,vector<int>> join(int x){
N+=x;
solve(x);
return {x,curr};
}
pair<int,vector<int>> leave(int x){
N-=x;
while(!curr.empty() and curr.back()>N)curr.erase(--curr.end());
solve(x);
return {x,curr};
}
# | 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... |