问题 L: a-b Problem

内存限制:256 MB 时间限制:3 S
题面:传统 评测方式:文本比较 上传者:
提交:9 通过:6

题目描述

Alice and Bob are playing a little game. There are n stones. Alice and Bob take turns picking stones, with Alice going first. Each person can only pick one stone at a time until all the stones are gone. Each stone has two attributes, Ai and Bi. When Alice picks a stone, she earns Ai points, and when Bob picks a stone, he earns Bi points. The total score for each person is the sum of the points they earn when picking a stone. Both players want to maximize the difference between their scores, aiming to have their own score minus the opponent's score as large as possible. The question is, what is the final result of Alice's score minus Bob's score?

输入格式

The first line contains a positive integer, T, representing the number of test cases, where 1T20.

Next, for each test case, the following format is repeated:

The first line contains a positive integer, n, where 1n10^5. The next n lines contain two integers, Ai and Bi, representing the two attributes of the ith stone. The values of Ai and Bi satisfy 0Ai,Bi10^9.

输出格式

For each test case, output one line containing an integer representing the answer.

输入样例 复制

2
3
0 2
1 2
3 3
3
1 0
2 3
0 4

输出样例 复制

1
-1