P6244 [USACO06OPEN] County Fair Events S

Background

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

Description

FJ is attending events. He wants to attend as many of the $N$ 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 $T$ and duration $L$, find the maximum number of events FJ can attend. FJ will not leave any event early.

Input Format

The first line contains an integer $N$. Lines $2$ to $N+1$: each line contains two integers $T$ and $L$ separated by a space, with the meaning described above.

Output Format

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

Explanation/Hint

$1\le T,L\le 10^5$ $1\le N\le 10^4$ Translated by ChatGPT 5