当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5596:GTW likes gt

题目描述
Long long ago, there were $n$ adorkable GT. Divided into two groups, they were playing games together, forming a column. The $i-th$ GT would randomly get a value of ability $b_i$. At the $i-th$ second, the $i-th$ GT would annihilate GTs who are in front of him, whose group differs from his, and whose value of ability is less than his.

In order to make the game more interesting, GTW, the leader of those GTs, would emit energy for $m$ times, of which the $i-th$ time of emitting energy is $c_i$. After the $c_i$ second, $b_1, b_2,...,b_{c_i}$ would all be added 1.

GTW wanted to know how many GTs would survive after the $n-th$ second.
输入解释
The first line of the input file contains an integer $T (\leq 5)$, which indicates the number of test cases.

For each test case, there are $n + m + 1$ lines in the input file.

The first line of each test case contains 2 integers $n$ and $m$, which indicate the number of GTs and the number of emitting energy, respectively.$(1\leq n,m \leq 50000)$

In the following $n$ lines, the $i-th$ line contains two integers $a_i$ and $b_i$, which indicate the group of the $i-th$ GT and his value of ability, respectively. $(0\leq a_i\leq 1, 1\leq b_i\leq 10^6)$

In the following $m$ lines, the $i-th$ line contains an integer $c_i$, which indicates the time of emitting energy for $i-th$ time.
输出解释
There should be exactly $T$ lines in the output file.

The $i-th$ line should contain exactly an integer, which indicates the number of GTs who survive.
输入样例
1
4 3
0 3
1 2
0 3
1 1
1
3
4
输出样例
3
提示
After the first seconds,$b_1=4,b_2=2,b_3=3,b_4=1$
After the second seconds,$b_1=4,b_2=2,b_3=3,b_4=1$
After the third seconds,$b_1=5,b_2=3,b_3=4,b_4=1$,and the second GT is annihilated by the third one.
After the fourth seconds,$b_1=6,b_2=4,b_3=5,b_4=2$
$c_i$ is unordered.
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5596

最后修改于 2020-10-25T23:24:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 131072/131072K(Java/Others)