2050: [USACO 2024 US Open Contest Gold] Problem 2. Grass Segments

文件提交:无需freopen 内存限制:256 MB 时间限制:2.000 S
评测方式:普通裁判 命题人:
提交:2 解决:1

题目描述

Bessie is planting some grass on the positive real line. She has N (2N2105) different cultivars of grass, and will plant the ith cultivar on the interval [i,ri] (0<i<ri109).

In addition, cultivar i grows better when there is some cultivar j (ji) such that cultivar j and cultivar i overlap with length at least ki (0<kirii). Bessie wants to evaluate all of her cultivars. For each i, compute the number of ji such that j and i overlap with length at least ki.

输入

The first line contains N.

The next N lines each contain three space-separated integers iri, and ki.

输出

The answers for all cultivars on separate lines.

样例输入

2
3 6 3
4 7 2

样例输出

0
1

提示

The overlaps of the cultivars is [4,6], which has length 2, which is at least 2 but not at least 3.

SAMPLE INPUT:

4

3 6 1

2 5 1

4 10 1

1 4 1

SAMPLE OUTPUT:

3

3

2

2

SAMPLE INPUT:

5

8 10 2

4 9 2

3 7 4

5 7 1

2 7 1

SAMPLE OUTPUT:

0

3

1

3

3

SCORING:

  • Input 4-5: N5000
  • Inputs 6-11: k is the same for all intervals
  • Inputs 12-20: No additional constraints.

In addition, for Inputs 5, 7, ..., 19, ri2N for all i.

来源/分类