algorithm - Unable to solve a homework (ACM-training) -
i have no idea how solve this: http://acm.sgu.ru/problem.php?contest=0&problem=311
please me one
i know can solved using segment tree don't know how
read of prices , set segment tree. each segment, store number , total cost of pieces prices lie in segment. that's of problem, , rest of answer rather vague in hopes learn something.
handling arrival of pieces straightforward o(log n)-time descent in segment tree.
handling purchase request o(log n)-time descent followed update if sale made. update may traverse large amount of segment tree , fast in amortized sense – interval should entered if , if there pieces in price range, , running time of removal should charged arrival.
Comments
Post a Comment