1193: Up the Stairs
内存限制:64 MB
时间限制:1.000 S
评测方式:文本比较
命题人:
提交:1
解决:1
题目描述

输入
One line with a positive number: the number of test cases. Then for each test case:
- One line with three numbers N, F, B with 1 ≤ N,F ≤ 1000 and 1 ≤ B ≤ 1000000: the number of persons, the number of floors (0=ground floor, F=penthouse) and the number of boxes that are still on the ground floor.
- N lines with two numbers fi and bi with 0 ≤ fi ≤ F and bi = 0 or bi = 1: the floors where the persons are initially and whether or not they have a box in their hands (1=box, 0=no box).
输出
One line with the amount of time (in minutes) it will take to get all the remaining boxes to the penthouse.
样例输入 复制
2
3 10 5
0 0
0 0
0 0
2 5 1
2 1
3 0
样例输出 复制
30
8