D building reconstruction

Time limit: - MS    Space limitations: - KB 
Benchmark description: 1s, 256m
Problem Description

A little outside of the building there is a large construction site, there are N buildings to be built on the site of the building. Every day, this house on site demolished and built, built also removed. He often bored looking out the window in a daze, they can see how much the number of houses.

To simplify the problem, we consider these events occur in a two-dimensional plane. A small segment position in a plane (0,0), the i-th building housing may be connected to a (i, 0) and (i, Hi) representation, where Hi is the height of the i-room building.
If the point of a height greater than 0 and (0,0) connection does not intersect the previous line presence on the building for, then This building is considered to be visible.

Construction team built a total of M days. Initially, all the buildings have not yet started to build, their height are both zero.
In the i-day, team building will house the horizontal axis is the height of Xi becomes Yi (height can be larger than the original - built, can be smaller than the original - demolition, or even remain unchanged - the construction crew that day what I did not do).
A little help please count after the completion of the construction team, he can see how many houses are every day?

Input Format

The first line of two positive integers N, M
Next M rows, each row two positive integers Xi, Yi

Output Format

M line, i-line of a building after the first integer A small day i can see how many buildings

Sample input 1

3 4
2 4
3 6
1 1000000000
1 1

Sample output 1

1
1
1
2

Sample input 2

10 100
6 166267291
4 764085103
1 12360641
1 846991393
6 383204345
2 69698641
9 12331341
1 772764651
5 131311041
10 46049537
6 690746401
2 145679903
10 758217
4 201987721
9 249525949
7 161049529
6 110578175
4 231517001
5 644489651
7 340648201
7 151799407
10 7480386
3 206257865
9 328935144
3 352739143
7 84581584
5 29535731
4 196598419
6 55312269
8 11283241
7 10289281
4 250134981
2 208241815
5 46222012
6 34664323
7 359037865
9 396005251
2 101892805
2 210317844
3 441658977
5 113743513
8 44192926
6 102944206
4 288727385
6 233930929
8 2996745
2 660629278
4 32747101
5 7218281
9 991959715
1 130023361
9 20174977
10 590823439
4 609043601
10 794927517
8 835448158
9 79194028
10 218902057
3 81328780
1 842713384
6 506252986
9 38734669
7 134763046
7 198136601
6 145100953
8 139458607
3 621701089
10 163368301
8 162641963
2 177393360
8 429881306
7 165305441
4 16342951
10 217025793
5 32343754
1 221071391
4 17866381
2 1999669
2 109659346
10 179614829
4 59706591
4 19298137
8 774219601
8 6099164
7 258624081
5 66188305
5 64116244
10 355183187
2 354022111
6 3929553
3 234438274
5 550657829
1 283731112
1 497844261
7 287715541
7 434450329
10 267779521
5 37026775
9 7125790
7 23094767

Sample output 2

1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

prompt

For all data
. 1 X-≤ I  ≤ N, the Y. 1 ≤ I  ≤ 10 . 9

N,M ≤ 100000

【analysis】

 

[Standard] Cheng

Guess you like

Origin www.cnblogs.com/Limbo-To-Heaven/p/11369646.html