![]() |
||||||||||
|
||||||||||
Problem DTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1 Accepted Submission(s): 1 Problem Description In Warcraft III, Destroyer is a large flying unit that must consume magic to sustain its mana. Breaking free of the obsidian stone that holds them, these monstrous creatures roar into battle, swallowing magic to feed their insatiable hunger as they move between battles and rain destruction down upon their foes. Has Spell Immunity. Attacks land and air units. ![]() The core skill of the Destroyer is so called Devour Magic, it takes all mana from all units in a area and gives it to the Destroyer. Now to simplify the problem, assume you have n units in a line, all unit start with 0 mana and can increase to infinity maximum mana. All unit except the Destroyer have mana regeneration 1 in per unit time. The Destroyer have m instructions t l r, it means, in time t, the Destroyer use Devour Magic on unit from l to r. We give you all m instructions in time order, count how many mana the Destroyer have devour altogether. Input The first line contains one integer T, indicating the test case. For each test case, the first contains two integer n, m(1 ≤ n, m ≤ 105). The the next m line each line contains a instruction t l r.(1 ≤ t ≤ 105, 1 ≤ l ≤ r ≤ n) Output For each test case, output the conrespornding result. Sample Input
Sample Output
Source | ||||||||||
|