#P6244. [USACO06OPEN] County Fair Events S

[USACO06OPEN] County Fair Events S

Background

This problem is a shortened version that keeps the original meaning unchanged.

Problem Description

FJ is attending events.

He wants to attend as many of the NN events as possible. After finishing one event, he can immediately attend the next one.

Given the list of events FJ can attend, their start time TT and duration LL, find the maximum number of events FJ can attend.

FJ will not leave any event early.

Input Format

The first line contains an integer NN.

Lines 22 to N+1N+1: each line contains two integers TT and LL separated by a space, with the meaning described above.

Output Format

Output only one line: the maximum number of events FJ can attend.

7
1 6
8 6
14 5
19 2
1 8
18 3
10 6
4

Hint

1T,L1051\le T,L\le 10^5

1N1041\le N\le 10^4

Translated by ChatGPT 5