제출 #781046

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
7810462023-07-12 16:21:52cig32Osumnjičeni (COCI21_osumnjiceni)C++17
110 / 110
757 ms51240 KiB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5 + 4;
struct node{
int upd, ans;
} a[4*MAXN];
void range_add(int l,int r,int constl,int constr,int idx,int val){
if(l<=constl && constr<=r){
a[idx].upd += val;
a[idx].ans += (constr-constl+1) * val;
return;
}
int mid = (constl + constr) >> 1;
if(mid<l || r<constl) range_add(l, r, mid+1, constr, 2*idx+2, val);
else if(constr<l || r<mid+1) range_add(l, r, constl, mid, 2*idx+1, val);
else{
range_add(l, r, constl, mid, 2*idx+1, val);
range_add(l, r, mid+1, constr, 2*idx+2, val);
}
a[idx].ans = a[2*idx+1].ans + a[2*idx+2].ans + (constr-constl+1) * a[idx].upd;
}
int query_sum(int l,int r,int constl,int constr,int idx){
if(l<=constl && constr<=r) return a[idx].ans;
int mid = (constl + constr) >> 1;
int sz = min(r, constr) - max(l, constl) + 1;
if(mid<l || r<constl) return sz * a[idx].upd + query_sum(l, r, mid+1, constr, 2*idx+2);
else if(constr<l || r<mid+1) return sz * a[idx].upd + query_sum(l, r, constl, mid, 2*idx+1);
else{
return sz * a[idx].upd + query_sum(l, r, constl, mid, 2*idx+1) + query_sum(l, r, mid+1, constr, 2*idx+2);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...