F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Lotus and Characters

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/131072 K (Java/Others)
Total Submission(s): 2819    Accepted Submission(s): 942


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 $\geq 0$ĄŁ
 

Input
First line is $T(0 \leq T \leq 1000)$ denoting the number of test cases.
For each test case,first line is an integer $n(1 \leq n \leq 26)$,followed by $n$ lines each containing 2 integers $val_i,cnt_i(|val_i|,cnt_i\leq 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
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-06-20 20:23:40, Gzip enabled