# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
479857 | couplefire | Distributing Candies (IOI21_candies) | C++17 | 557 ms | 46876 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;
#define ll long long
const int N = 1<<18;
struct node{ll sum, mn, mx;} tree[N<<1];
int n, q, cap[N], q_l[N], q_r[N], val[N];
vector<int> start[N], stop[N], res;
node comb(node a, node b){
node res; res.sum = a.sum+b.sum;
res.mn = min(a.mn, a.sum+b.mn);
res.mx = max(a.mx, a.sum+b.mx);
return res;
}
void upd(int pos, int nval, int v = 1, int tl = 0, int tr = N-1){
if(tr<pos || tl>pos) return;
if(tl==tr) return void(tree[v] = {nval, min(nval, 0), max(nval, 0)});
int tm = (tl+tr)>>1;
upd(pos, nval, v<<1, tl, tm);
upd(pos, nval, v<<1|1, tm+1, tr);
tree[v] = comb(tree[v<<1], tree[v<<1|1]);
}
node get(int l, int r, int v = 1, int tl = 0, int tr = N-1){
if(tr<l || tl>r) return {0, (ll)1e18, -(ll)1e18};
if(l<=tl && tr<=r) return tree[v];
int tm = (tl+tr)>>1;
# | 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... |