# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
852376 | vjudge1 | Holiday (IOI14_holiday) | C++17 | 265 ms | 15000 KiB |
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 <iostream>
#include <vector>
#include <algorithm>
#include "holiday.h"
using namespace std;
pair<int, int> a[400005];
long long f[400005], g[400005], res = 0;
int d;
struct DAY {
long long int res, c;
};
DAY t[1600005];
void update(int v, int x) {
v += 400005;
if (x < 0) t[v].c = 0;
else t[v].c = 1;
t[v].res += x;
v /= 2;
while (v > 0) {
t[v].c = t[v * 2].c + t[v * 2 + 1].c;
t[v].res = t[v * 2].res + t[v * 2 + 1].res;
v /= 2;
}
}
long long int sum(int v, int l, int r, int x) {
if (t[v].c == 0 || x <= 0) return 0;
if (t[v].c <= x) return t[v].res;
int mid = (l + r) / 2;
if (t[v * 2 + 1].c >= x) return sum(v * 2 + 1, mid + 1, r, x);
return t[v * 2 + 1].res + sum(v * 2, l, mid, x - t[v * 2 + 1].c);
# | 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... |