Hi guy, i am stucking in this problem : https://cses.fi/problemset/task/1735/
Here is my code : https://cses.fi/paste/567abb6bc35edc71146fae/
I have no idea why i got WA. Can anybody explain for me what was wrong in my concept ?
(Sorry because my English:"((( )
UPD : I got AC, my code has a big mistake follow smax said below.
Lines 50-53:
You set the left and right child's sums, but then you don't propagate
it[id].sv
toit[l].sv
andit[r].sv
, so any children underneath the left and right children don't get set properly.