Apple trees 2 - MarisaOJ: Marisa Online Judge

Apple trees 2

Time limit: 1000 ms
Memory limit: 256 MB
Marisa planted n apple trees in a row. There are q rainy days. On each day i, a certain amount of rainwater, denoted as wi liters, was received by each tree within the range [li,ri]. Each tree, denoted as the ith tree, requires a specific amount of water, denoted as Ai liters, in order to undergo mutation. Marisa seeks to determine the day on which each tree mutates. ### Input - The first line contains two integers n,q. - The second line contains n integer Ai. - The next q lines, each line three integers li,ri,wi. ### Output - Print n integers, the ith one is the day on which tree i mutates. Or print -1 if it won't mutate. ### Constraints - 1≤n,q≤105 - 1≤li≤ri≤n. - 1≤wi,Ai≤109. ### Example Input: 5337216153232353 Output: 1-1113