CF2038J.Waiting for...

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Waiting for...

Monocarp is waiting for a bus at the bus stop. Unfortunately, there are many people who want to ride a bus too.

You are given a list of events of two types:

  • B bib_i — a bus with bib_i free seats arrives at the stop;
  • P pip_i — pip_i people arrive at the stop.

These events are listed in a chronological order.

When a bus arrives, the following happens. All people at the bus stop (except for Monocarp) try to enter the bus. If there are enough free seats for all of them, then they all enter the bus. Otherwise, some people remain at the bus stop (the number of people who enter the bus is equal to the number of free seats).

If there is still at least one free seat after all people (except for Monocarp) enter the bus, then Monocarp can decide to enter this bus as well (but he might choose to wait for another bus). For each bus, you have to determine if it is possible for Monocarp to take that bus.

Input

The first line contains one integer nn (1n103)(1 \le n \le 10^3) — the number of events.

Then, nn lines follow. The ii-th of them contains the description of the ii-th event in one of the two following formats:

  • B bib_i (1bi1061 \le b_i \le 10^6) — a bus with bib_i free seats arrives at the stop;
  • P pip_i (1pi1061 \le p_i \le 10^6) — pip_i people arrive at the stop.

Additional constraint on the input: there is at least one event of type B.

Output

For each event of type B, print YES if it is possible for Monocarp to take the corresponding bus, or NO otherwise (case-insensitive).

Samples

10
P 2
P 5
B 8
P 14
B 5
B 9
B 3
P 2
B 1
B 2
YES
NO
NO
YES
NO
YES

在线编程 IDE

建议全屏模式获得最佳体验