# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1071713 | isaachew | Two Dishes (JOI19_dishes) | C++17 | 5981 ms | 448812 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>
/*
Why is this Diamond 1?
Shift segtree and range max
Too slow for BOJ?
*/
std::pair<long long,long long> combine(std::pair<long long,long long> a,std::pair<long long,long long> b){
return {a.first+b.first,std::max(a.second+b.first,b.second)};
}
struct segtree{
int size;
std::vector<std::pair<long long,long long>> nodes;
segtree(){}
void init(int n){
size=n;
nodes.resize(2*n-1,{0,0});
}
void update(int l,int r,std::pair<long long,long long> tr,int nl,int nr,int ni){
if(r<=nl||l>=nr)return;
if(l<=nl&&r>=nr){
nodes[ni]=combine(nodes[ni],tr);
return;
}
//pushdown
int nm=(nl+nr)/2;
nodes[ni+1]=combine(nodes[ni+1],nodes[ni]);
nodes[ni+2*(nm-nl)]=combine(nodes[ni+2*(nm-nl)],nodes[ni]);
nodes[ni]={0,-1e18};
update(l,r,tr,nl,nm,ni+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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |