Problem 3050 --Roundgod and Milk Tea

3050: Roundgod and Milk Tea

"
Time Limit $6$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Roundgod is a famous milk tea lover at Nanjing University second to none. This year, he plans to conduct a milk tea festival. There will be nn classes participating in this festival, where the iith class has aiai students and will make bibi cups of milk tea. 

Roundgod wants more students to savor milk tea, so he stipulates that every student can taste at most one cup of milk tea. Moreover, a student can't drink a cup of milk tea made by his class. The problem is, what is the maximum number of students who can drink milk tea?
The first line of input consists of a single integer TT (1≤T≤25)(1≤T≤25), denoting the number of test cases. 

Each test case starts with a line of a single integer nn (1≤n≤106)(1≤n≤106), the number of classes. For the next nn lines, each containing two integers a,ba,b (0≤a,b≤109)(0≤a,b≤109), denoting the number of students of the class and the number of cups of milk tea made by this class, respectively. 

It is guaranteed that the sum of nn over all test cases does not exceed 6×1066×106.
For each test case, print the answer as a single integer in one line.
1
2
3 4
2 1
3

推荐代码 查看3050 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$1464 $ms] 淡意的温柔 591148 2020-06-06 08:47:08
内存最少[$16744 $KB] 淡意的温柔 591148 2020-06-06 08:47:08
第一AC 淡意的温柔 591148 2020-06-06 08:47:08
第一挑战 淡意的温柔 591148 2020-06-06 08:47:08

赛题来源/所属竞赛 2019 Multi-University Training Contest 8 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛