Grass Segments

시간 제한2초메모리 제한1024 MB

요약
각 구간 i에 대해, 길이가 k_i 이상 겹치는 다른 구간의 개수를 센다.
난이도

보통10점 중 7점

유형
정렬, 이분 탐색, 구간
정답자
아직 제출이 없습니다

문제

Bessie is planting some grass on the positive real line. She has NN (2≤N≤2⋅1052\le N\le 2\cdot 10^5) different cultivars of grass, and will plant the iith cultivar on the interval \[ℓ_i,r_i]\[\ell\_i, r\_i] (0<ℓ_i<r_i≤1090 < \ell\_i < r\_i \leq 10^9).

In addition, cultivar ii grows better when there is some cultivar jj (j≠ij\neq i) such that cultivar jj and cultivar ii overlap with length at least k_ik\_i (0<k_i≤r_i−ℓ_i0 < k\_i \leq r\_i - \ell\_i). Bessie wants to evaluate all of her cultivars. For each ii, compute the number of j≠ij\neq i such that jj and ii overlap with length at least k_ik\_i.

입력

The first line contains NN.

The next NN lines each contain three space-separated integers ℓ_i\ell\_i, r_ir\_i, and k_ik\_i.

출력

The answers for all cultivars on separate lines.

예제3

  1. 예제 1

    입력
    2
    3 6 3
    4 7 2
    
    예상 출력
    0
    1
    
  2. 예제 2

    입력
    4
    3 6 1
    2 5 1
    4 10 1
    1 4 1
    
    예상 출력
    3
    3
    2
    2
    
  3. 예제 3

    입력
    5
    8 10 2
    4 9 2
    3 7 4
    5 7 1
    2 7 1
    
    예상 출력
    0
    3
    1
    3
    3