We have a tree with $N$ nodes. $N \le 10^5.$ Each node has a value $V$ associated with it. Now we have $Q$ $(\le 10^5)$ queries. There are two types of queries:
Q X Y: in this type of query we have to decrement each node of the subtree rooted at $X$ by value $Y$.
C X: in this type of query we have to count the number of nodes in the subtree rooted at $X$ that are $\le 0$.
Here is my approach: I can perform the update query in $O(N)$ along with some sort of lazy propogation. The count query can be thus performed in constant time.
But I am more than sure that there will be a better approach to handle update queries. Possibly a $O(\log N)$ bound for both updates and counts. Is there a way I could map this tree into a segment tree or a bit.
Any approach would be appreciated.