You are given the number $m$ and $m$ intervals of the form $a_i, b_i, v_i$, where $a_i<=b_i$ and $v_i>0$ and also a number $n$ and an array $s$ of length $n$, where $s_i>0$. In one operation you can choose an interval say $j$ and decrease the values of $s_i$ by 1, where $a_j<=i<=b_j$, and you can choose interval $j$ at most $v_j$ times. The task is to find the minimum number of operations required to make all elements of $s$ non-positive.
My approach is some greedy where I sort the intervals by the starting point, and then iterate over the values of $s$ and if $s_i$ is positive I repeatedly find the first starting interval that contains index i and apply the minimum necesary ammount of operations. The way I do the update it is with segment trees. Overall, I am not convinced this greedy approach is right.