#include "light.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> cur;
void prepare() {
cur = {1};
}
pair<ll, vector<ll>> join(ll p) {
ll cz = cur.back() + p;
vector<ll> newcur;
for (ll i = 1; i <= cz; i *= 2) {
newcur.push_back(i);
newcur.push_back(cz-i+1);
}
sort(newcur.begin(), newcur.end());
newcur.resize(unique(newcur.begin(), newcur.end()) - newcur.begin());
ll t = 0;
for (ll i : newcur) {
t = max(t, i - *(upper_bound(cur.begin(), cur.end(), i) - 1));
}
cur = newcur;
return make_pair(t, cur);
}
pair<ll, vector<ll>> leave(ll p){
ll cz = cur.back() - p;
vector<ll> newcur;
for (ll i = 1; i <= cz; i *= 2) {
newcur.push_back(i);
newcur.push_back(cz-i+1);
}
sort(newcur.begin(), newcur.end());
newcur.resize(unique(newcur.begin(), newcur.end()) - newcur.begin());
ll t = 0;
for (ll i : newcur) {
t = max(t, i - *(upper_bound(cur.begin(), cur.end(), i) - 1));
}
cur = newcur;
return make_pair(t, cur);
}
# | 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... |