QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#3679. 楼房重建

الإحصائيات

问题描述

小 A 的楼房外有一大片施工工地,工地上有 $N$ 栋待建的楼房。每天,这片工地上的房子拆了又建、建了又拆。他经常无聊地看着窗外发呆,数自己能够看到多少栋房子。

为了简化问题,我们考虑这些事件发生在一个二维平面上。小 A 在平面上 $(0,0)$ 点的位置,第 $i$ 栋楼房可以用一条连接 $(i,0)$ 和 $(i,H_i)$ 的线段表示,其中 $H_i$ 为第 $i$ 栋楼房的高度。如果这栋楼房上任何一个高度大于 $0$ 的点与 $(0,0)$ 的连线没有与之前的线段相交,那么这栋楼房就被认为是可见的。

施工队的建造总共进行了 $M$ 天。初始时,所有楼房都还没有开始建造,它们的高度均为 $0$。在第 $i$ 天,建筑队将会将横坐标为 $X_i$ 的房屋的高度变为 $Y_i$ (高度可以比原来大---修建,也可以比原来小---拆除,甚至可以保持不变---建筑队这天什么事也没做)。请你帮小 A 数数每天在建筑队完工之后,他能看到多少栋楼房?

输入格式

第一行两个正整数 $N,M$

接下来 $M$ 行,每行两个正整数 $X_i,Y_i$

输出格式

$M$ 行,第 $i$ 行一个整数表示第 $i$ 天过后小 A 能看到的楼房有多少栋

样例输入

3 4
2 4
3 6
1 1000000000
1 1

样例输出

1
1
1
2

数据约定

对于所有的数据 $1 \leq X_i \leq N$,$1 \leq Y_i \leq 10^9$

测试点
$N,M$
1
$\leq 100$
2
$\leq 5\,000$
3
$\leq 50\,000$
4
$\leq 100\,000$
5
$\leq 30\,000$
6
$\leq 50\,000$
7
$\leq 70\,000$
8
$\leq 80\,000$
9
$\leq 90\,000$
10
$\leq 100\,000$

其他条件:

  • 测试点 $1 \sim 4$:建筑队每天等概率随机选择一栋房屋将其改造成 $1 \sim 10^9$ 内的等概率随机高度。
  • 测试点 $5 \sim 10$:无。
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.