#C4632. Counting Late Processes
Counting Late Processes
Counting Late Processes
You are given a set of test cases. In each test case, several processes must be executed sequentially. Each process is characterized by an execution time \(T_i\) and a deadline \(D_i\). As the processes are executed in order, the cumulative time increases, and if at any point the cumulative execution time exceeds the corresponding deadline, that process is labeled as late.
Your task is to determine how many processes are late for each test case.
Note: For a test case with zero processes, the answer is 0.
inputFormat
The input is read from standard input (stdin) and has the following format:
T N1 T11 D11 T12 D12 ... N2 T21 D21 T22 D22 ... ... NT TN1 DN1 TN2 DN2 ...
Where:
T
is the number of test cases.- For each test case, the first integer
N
indicates the number of processes. - Each of the following
N
lines contains two integers: the execution time \(T_i\) and the deadline \(D_i\) for that process.
outputFormat
For each test case, output a single line containing one integer: the number of processes that are late.
## sample2
3
2 5
3 6
1 8
4
4 10
2 8
3 6
2 5
0
2
</p>