hdu6011 Lotus and Characters
来源:互联网 发布:拳皇13se出招优化补丁 编辑:程序博客网 时间:2024/04/29 21:23
Lotus and Characters
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131072 K (Java/Others)Total Submission(s): 284 Accepted Submission(s): 102
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 。
Since it's valid to construct an empty string,the answer is always
Input
First line is T(0≤T≤1000) denoting the number of test cases.
For each test case,first line is an integern(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.
For each test case,first line is an integer
Output
For each test case.output one line containing a single integer,denoting the answer.
Sample Input
225 16 23-5 32 11 1
Sample Output
355
Source
BestCoder Round #91
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <cmath>using namespace std;const int maxn = 260010;int p,n,ans,now;int save[maxn];bool compare(int a,int b){ return a>b;}int main(){ int t,i,j,a,b,tot; scanf("%d",&t); while(t--){ scanf("%d",&n); p = 0; for(i=1;i<=n;i++){ scanf("%d%d",&a,&b); for(j=1;j<=b;j++){ save[++p] = a; } } sort(save+1, save+1+p,compare); tot = p; int last; ans = 0; p = 0; while(1){ last = ans; ans += save[++p]; for(i=1;i<p;i++){ ans += save[i]; } if(ans<last){ ans = last; break; } if(p==tot){ break; } } printf("%d\n",ans); } return 0;}
0 0
- hdu6011 Lotus and Characters
- HDU6011 Lotus and Characters
- HDU6011 Lotus and Characters
- hdu6011 -Lotus and Characters
- Lotus and Characters
- Lotus and Characters
- Lotus and Characters
- Lotus and Characters
- Lotus and Characters
- Lotus and Characters
- hdu----Lotus and Characters
- Lotus and Characters
- HDU 6011 Lotus and Characters
- 【HDU 6011 Lotus and Characters】
- hdu 6011 lotus and characters
- BestCoder#91Lotus and Characters
- 【HDOJ】【BC91】Lotus and Characters
- HDU 6011 Lotus and Characters
- 【IOS类扩展之Hex值颜色转换】UIColor+Hex
- tomcat下配置https环境
- Orange's 一个操作系统的实现
- MyBatis中关于别名typeAliases的设置
- python 合并 累加两个dict
- hdu6011 Lotus and Characters
- bootstrapValidator与My97日期校验
- 怎么样用qt编写串口通讯
- Apache Shiro权限控制实战,权限控制SpringMVC + Mybatis + Shiro
- 强制https访问,在浏览器中输入http的访问地址自动转换为https,端口问题
- webservice之REST以及RESTful的实现
- python 获取程序所在路径再写log
- okhttp3.2.0适配https,虽然网络上有很多文章。在此借助前人的经验,做一些处理。
- 跨界 +赋能——互联网的下一个关键词