### Woburn Challenge 2017-18 Round 2 - Senior Division

## Problem 3: Battle of the Pelennor Fields

An enormous, decisive battle is about to take place on the Pelennor Fields before the city of Minas Tirith! A noble army of Gondorian men will engage in battle against Sauron's evil army of orcs in an attempt to save their home and all of Middle Earth. Gandalf has given you your own vital task – not to actually participate in combat, but to report to him the state of the battle as it unfolds.

The battlefield can be represented as an infinite number line, and is initially empty. `N` (1 ≤ `N` ≤ 300,000) events will then occur over the course of the battle, one after another. The `i`-th event's type is indicated by the value `E _{i}` (1 ≤

`E`≤ 2):

_{i}- If
`E`= 1, then an orc arrives on the battlefield at position_{i}`O`(0 ≤_{i}`O`≤ 10_{i}^{9}). - Otherwise, if
`E`= 2, then a Gondorian archer arrives on the battlefield at position_{i}`A`(0 ≤_{i}`A`≤ 10_{i}^{9}), and having a bow range of`R`(1 ≤_{i}`R`≤ 10_{i}^{9}). Such an archer is able to shoot any orcs which are at most`R`units of distance away from_{i}`A`._{i}

All `N` combatants' positions are distinct.

An orc is "vulnerable" if there's at least one archer on the battlefield who is able to shoot that orc. After each of the `N` events, you'd like to report to Gandalf the number of orcs currently on the battlefield which are not vulnerable.

### Subtasks

In test cases worth 4/27 of the points, `N` ≤ 1000 and `R _{i}` = 1 for each applicable

`i`.

In test cases worth another 4/27 of the points,

`R`= 1 for each applicable

_{i}`i`.

In test cases worth another 8/27 of the points,

`R`= 10

_{i}^{6}for each applicable

`i`.

### Input Format

The first line of input consists of a single integer, `N`.

`N` lines follow, the `i`-th of which consists of a single integer, `E _{i}`, followed by either 1 more integer

`O`(if

_{i}`E`= 1) or 2 more integers

_{i}`A`and

_{i}`R`(if

_{i}`E`= 2), for

_{i}`i`= 1..

`N`.

### Output Format

Output `N` lines, the `i`-th of which should consist of a single integer, the number of non-vulnerable orcs on the battlefield after the first `i` events.

### Sample Input

7 1 15 1 22 2 18 3 1 19 2 5 12 1 23 1 0

### Sample Output

1 2 1 1 1 2 2

### Sample Explanation

After the 2nd event, there are still no archers on the field, meaning that both orcs are non-vulnerable. After the 3rd event, the newly-arrived archer is just barely able to shoot the first orc, while the second orc is too far away and so is still non-vulnerable. After the 7th event, the orcs at positions 22 and 23 are still non-vulnerable, while the remaining 3 orcs are vulnerable.

All Submissions

Best Solutions

**Point Value:** 15 (partial)

**Time Limit:** 6.00s

**Memory Limit:** 128M

**Added:** Feb 23, 2018

**Author:** SourSpinach

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

It's quiet in here...