# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
521568 | eecs | Distributing Candies (IOI21_candies) | C++17 | 379 ms | 38424 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 "candies.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200010;
int C;
ll mn[maxn << 2], mx[maxn << 2], tag[maxn << 2];
vector<pair<int, int>> Q[maxn];
#define mid (l + r >> 1)
#define ls (k << 1)
#define rs (k << 1 | 1)
void apply(int k, ll v) { mn[k] += v, mx[k] += v, tag[k] += v; }
void pushdown(int k) { apply(ls, tag[k]), apply(rs, tag[k]), tag[k] = 0; }
void add(int k, int l, int r, int ql, int qr, ll v) {
if (l >= ql && r <= qr) { apply(k, v); return; }
pushdown(k);
if (mid >= ql) add(ls, l, mid, ql, qr, v);
if (mid < qr) add(rs, mid + 1, r, ql, qr, v);
mn[k] = min(mn[ls], mn[rs]), mx[k] = max(mx[ls], mx[rs]);
}
int find(int k, int l, int r, ll &cmn, ll &cmx) {
if (l < r && max(cmx, mx[k]) - min(cmn, mn[k]) >= C) {
pushdown(k);
int t = find(rs, mid + 1, r, cmn, cmx);
return ~t ? t : find(ls, l, mid, cmn, cmx);
} else {
Compilation message (stderr)
# | 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... |