#C3897. Task Deadline Completion
Task Deadline Completion
Task Deadline Completion
You are given n tasks. Each task is defined by two integers: its duration and its deadline. The tasks must be performed sequentially in the given order. Let \(t_i\) be the duration and \(d_i\) be the deadline of the \(i\)-th task. Define the cumulative time \(S_k = \sum_{i=1}^{k} t_i\) for the first \(k\) tasks. The objective is to determine whether the tasks can be completed within their deadlines, i.e., for every \(1 \le k \le n\), the condition \(S_k \le d_k\) must hold.
If the condition holds for all tasks, output Yes
; otherwise, output No
.
inputFormat
The first line contains an integer n (1 ≤ n ≤ 105), the number of tasks. Each of the following n lines contains two space-separated integers duration and deadline (1 ≤ duration, deadline ≤ 109), representing the duration and deadline of a task.
outputFormat
Output a single line with Yes
if all tasks can be completed within their deadlines, otherwise output No
.
3
3 5
2 8
1 10
Yes