码迷,mamicode.com
首页 > 其他好文 > 详细

BestCoder Round #91

时间:2017-05-03 21:17:38      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:efi   cal   script   out   empty   each   lotus   for   bestcode   

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

标签:efi   cal   script   out   empty   each   lotus   for   bestcode   

原文地址:http://www.cnblogs.com/jianglingxin/p/6803870.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!