CF1710B.Rain
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are the owner of a harvesting field which can be modeled as an infinite line, whose positions are identified by integers.
It will rain for the next n days. On the i -th day, the rain will be centered at position xi and it will have intensity pi . Due to these rains, some rainfall will accumulate; let aj be the amount of rainfall accumulated at integer position j . Initially aj is 0 , and it will increase by max(0,pi−∣xi−j∣) after the i -th day's rain.
A flood will hit your field if, at any moment, there is a position j with accumulated rainfall aj>m .
You can use a magical spell to erase exactly one day's rain, i.e., setting pi=0 . For each i from 1 to n , check whether in case of erasing the i -th day's rain there is no flood.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤104 ). The description of the test cases follows.
The first line of each test case contains two integers n and m ( 1≤n≤2⋅105 , 1≤m≤109 ) — the number of rainy days and the maximal accumulated rainfall with no flood occurring.
Then n lines follow. The i -th of these lines contains two integers xi and pi ( 1≤xi,pi≤109 ) — the position and intensity of the i -th day's rain.
The sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case, output a binary string s length of n . The i -th character of s is 1 if after erasing the i -th day's rain there is no flood, while it is 0, if after erasing the i -th day's rain the flood still happens.
输入输出样例
输入#1
4 3 6 1 5 5 5 3 4 2 3 1 3 5 2 2 5 1 6 10 6 6 12 4 5 1 6 12 5 5 5 9 7 8 3
输出#1
001 11 00 100110
说明/提示
In the first test case, if we do not use the spell, the accumulated rainfall distribution will be like this:
If we erase the third day's rain, the flood is avoided and the accumulated rainfall distribution looks like this:
In the second test case, since initially the flood will not happen, we can erase any day's rain.
In the third test case, there is no way to avoid the flood.
输入解题思路,AI测评打分。不知道怎么写?