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 <cstring>
#include <vector>
using namespace std;
const int N = 150;
typedef vector<long long> vl;
typedef pair<long long, vl> plvl;
long long xx[N], xx_[N]; int n, n_;
void prepare() {
n = 0;
xx[n++] = 1;
}
void update(long long d) {
for (int i = 0; i < n; i++)
xx[i] += d;
n_ = 0;
xx_[n_++] = 1;
for (int i = 0; i < n; i++) {
if (xx[i] <= xx_[n_ - 1])
continue;
long long x;
while ((x = xx_[n_ - 1] * 2 + 1) < xx[i]) {
while (n_ >= 2 && xx_[n_ - 2] * 2 + 1 >= x)
n_--;
xx_[n_++] = x;
}
x = xx[i];
while (n_ >= 2 && xx_[n_ - 2] * 2 + 1 >= x)
n_--;
xx_[n_++] = x;
}
memcpy(xx, xx_, (n = n_) * sizeof *xx_);
}
vl query() {
vl aa(n);
for (int i = 0; i < n; i++)
aa[i] = xx[n - 1] - xx[n - 1 - i] + 1;
return aa;
}
plvl join(long long d) {
update(d);
return { d, query() };
}
plvl leave(long long d) {
update(-d);
return { d, query() };
}
# | 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... |