BestCoder Round #91

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BestCoder Round #91相关的知识,希望对你有一定的参考价值。

A.Lotus and Characters(技巧 + 思维)

Problem Description

Lotus has n kinds of characters,each kind of characters has a value and a amount.She wants to construct a string using some of these characters.Define the value of a string is:its first character‘s value*1+its second character‘s value *2+...She wants to calculate the maximum value of string she can construct.Since it‘s valid to construct an empty string,the answer is always ≥0。

Input

First line is T(0≤T≤1000) denoting the number of test cases.For each test case,first line is an integer n(1≤n≤26),followed by n lines each containing 2 integers vali,cnti(|vali|,cnti≤100),denoting the value and the amount of the ith character.

Output

For each test case.output one line containing a single integer,denoting the answer.

Sample Input

2
2
5 1
6 2
3
-5 3
2 1
1 1

Sample Output

35
5

 

以上是关于BestCoder Round #91的主要内容,如果未能解决你的问题,请参考以下文章

BestCoder Round #91

BestCoder Round #91 1002 Lotus and Horticulture

BestCoder Round #75

BestCoder Round #92

ACM学习历程—BestCoder Round #75

BestCoder Round #88