Lotus and Characters
来源:互联网 发布:襄阳网络电视台台湾周 编辑:程序博客网 时间:2024/04/29 18:46
Lotus and Characters
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131072 K (Java/Others)Total Submission(s): 198 Accepted Submission(s): 73
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
一开始想的确实太简单了,想着负值的绝对不存在,接着敲了一发A掉就没再管,以后做BC必须得想好啊。很不友好呐QAQ。
题解相信大家都看了,我就放个代码就好啦。
#include <bits/stdc++.h>using namespace std;const int MAXN=1e5+7;int n,m;struct node{ int data; int num; bool operator<(const node &a)const { return data>a.data; }}p[30];int main(){ int i,j; int t; scanf("%d",&t); while(t--) { scanf("%d",&n); for(i=0;i<n;++i) { scanf("%d%d",&p[i].data,&p[i].num); } long long ans=0; long long t=0; sort(p,p+n); for(i=0;i<n;++i) { for(j=0;j<p[i].num;++j) { t+=p[i].data;//新进来一个字符到队列的总贡献 if(t>0) { ans+=t; } else break; } if(j<p[i].num)break; } printf("%I64d\n",ans); } return 0;}
1 0
- Lotus and Characters
- Lotus and Characters
- hdu6011 Lotus and Characters
- HDU6011 Lotus and Characters
- Lotus and Characters
- Lotus and Characters
- Lotus and Characters
- Lotus and Characters
- HDU6011 Lotus and Characters
- hdu----Lotus and Characters
- Lotus and Characters
- hdu6011 -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
- Toolbar随着ScrollView滑动透明度渐变效果实现
- python 4-3 如何调整字符串中文本格式re.sub(p,r'\1/\2',str1)/re.sub('(?P<Name>p),'\g<Name>',str1)
- FastScrollView实现及其setContentSize与setInnerContainerSize理解
- logcat内容备份
- 用 Docker 创建 serverless 应用
- Lotus and Characters
- oracle查看被锁的表和解锁
- 分解质因数
- ioncube加密与解密 php代码
- MFC MainFrame中的 OnShowWindow一个bug
- Hadoop集群环境搭建
- 告诉你一个去除PDF文件水印简单快速的方法
- 最近在C++ 中用到extern关键字的一点点感悟
- raise number of connections