Jenga Tower

시간 제한3초메모리 제한2048 MB

요약
각 블록을 제거했을 때, 위에 쌓인 블록들의 무게중심이 모든 블록의 구간 안에 들어오는지 판정한다.
난이도

보통10점 중 7점

유형
누적 합, 동적 계획법, 수학
정답자
아직 제출이 없습니다

문제

The city of Ruralia is building a tower consisting of nn Jenga blocks.

Each block is rectangular with height 11, width r_i−l_ir\_i - l\_i, and density 11 and will be placed on the plane, axis-aligned with its bottom left corner lying on the coordinates (l_i,n−i)(l\_i,n-i).

After all the blocks have been placed, all of the scaffolding will be removed, and the tower will stay standing if for each block ii the center of mass of all blocks above ii is between l_il\_i and r_ir\_i.

More formally, a tower is stable if and if only for all 2≤i≤n2 \leq i \leq n the following inequality holds.

l_i≤∑_j=1i−1(r_j−l_j)⋅l_j+r_j2∑_j=1i−1(r_j−l_j)≤r_il\_i \leq \frac{\sum\_{j=1}^{i-1} (r\_j - l\_j) \cdot \frac{l\_j + r\_j}2}{\sum\_{j=1}^{i-1} (r\_j - l\_j)}\leq r\_i

Unfortunately, you have received news that one of the Jenga blocks has been missing but you are unsure which one. When the shipment arrives, the builders of Ruralia will place the blocks as originally planned, except the one missing block will not be placed and all blocks above it will be moved downwards by 11.

However, before building the tower, the builders want to know if the resulting tower will be stable. Thus, they have asked you to determine for each block ii whether the structure with block ii missing is stable.

Do note that it is not necessarily the case that the original tower plan was stable.

입력

The first line contains a single integer nn (1≤n≤2⋅1051 \leq n \leq 2\cdot 10^5) --- the number of blocks in the original tower.

The following nn lines each contain two integers l_i,r_il\_i, r\_i (1≤l_i<r_i≤1061 \leq l\_i < r\_i \leq 10^6)--- the endpoints of block ii.

It is not necessary that the tower in the input is stable.

출력

Output nn lines.

On line ii, output "YES" or "NO" --- corresponding to whether the tower will be stable if block ii is removed.

예제2

  1. 예제 1

    입력
    5
    0 10
    4 10
    0 6
    4 10
    0 6
    
    예상 출력
    NO
    YES
    NO
    YES
    YES
    
  2. 예제 2

    입력
    4
    6 8
    0 3
    0 8
    0 6
    
    예상 출력
    YES
    YES
    NO
    NO