SP14977 UOFTBB - Attack of the Bloons

Description

The Bloons (not to be confused with balloons) are attacking! They are attempting to navigate your course of $ L $ ( $ 1 \leq L \leq 1000 $ ) cells, laid out in a row and numbered from $ 1 $ to $ L $ . You don't know what they'll do to you if they manage reach the end, and you don't want to find out! To that end, you've constructed some defensive towers along the course. You might say that this is a Bloons Tower Defense. There are $ N $ ( $ 1 \leq N \leq 1000 $ ) towers ready to take out any Bloons that get close. The $ i $ th tower is located next to cell $ C_i $ ( $ 1 \leq C_i \leq L $ ), and can launch darts at any Bloons that are no more than $ R_i $ ( $ 0 \leq R_i \leq 1000 $ ) cells away - that is, Bloons in cells $ C_i-R_i $ to $ C_i+R_i $ , inclusive. Every second, it will do $ D_i $ ( $ 1 \leq D_i \leq 10^9 $ ) HP worth of damage to any Bloons in this range. $ M $ ( $ 1 \leq M \leq 1000 $ ) Bloons will attempt to float through your course, one after another. The $ i $ th Bloon begins with $ H_i $ ( $ 1 \leq H_i \leq 10^9 $ ) HP, and will pop as soon as it has taken at least that much damage in total. Each Bloon starts in cell 1, and moves along the course at a speed of 1 cell per second. If a Bloon moves past cell $ L $ , it safely exits the course and can no longer be popped. There are $ T $ ( $ 1 \leq T \leq 20 $ ) scenarios as described above. For each, you'd like to determine how far along the course each of the $ M $ Bloons will make it.

Input Format

First line: 1 integer, $ T $ For each scenario: First line: 2 integers, $ L $ and $ N $ Next $ N $ lines: 3 integers, $ C_i $ , $ R_i $ , and $ D_i $ , for $ i = 1..N $ Next line: 1 integer, $ M $ Next $ M $ lines: 1 integer, $ H_i $ , for $ i = 1..M $

Output Format

For each scenario: $ M $ lines: If the $ i $ th Bloon will survive the course, the string "Bloon leakage" (without quotes) - otherwise, 1 integer, the furthest cell which the $ i $ th Bloon will reach, for $ i = 1..M $