# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
232247 | smilu2244 | Holiday (IOI14_holiday) | C++14 | 0 ms | 0 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 101010;
const int MAX_SEG = MAX_N*4;
struct Seg {
ll sum[MAX_SEG];
int cnt[MAX_SEG];
void clear() {
memset(sum, 0x00, sizeof(sum));
memset(cnt, 0x00, sizeof(cnt));
}
void update(int n, int s, int e, int x, ll val) {
if (x < s || x > e) return;
if (s == e) {
if (val >= 0) {
sum[n] = val;
cnt[n] = 1;
} else {
sum[n] = cnt[n] = 0;
}
} else {
int m = (s + e) >> 1, l = n << 1, r = l | 1;
if (x <= m) update(l, s, m, x, val);
else update(r, m+1, e, x, val);
sum[n] = sum[l] + sum[r];
cnt[n] = cnt[l] + cnt[r];