HD6015 Skip the Class
来源:互联网 发布:c语言for循环打印图形 编辑:程序博客网 时间:2024/05/16 09:42
Skip the Class
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1078 Accepted Submission(s): 625
Problem Description
Finally term begins. luras loves school so much as she could skip the class happily again.(wtf?)
Luras will take n lessons in sequence(in another word, to have a chance to skip xDDDD).
For every lesson, it has its own type and value to skip.
But the only thing to note here is that luras can't skip the same type lesson more than twice.
Which means if she have escaped the class type twice, she has to take all other lessons of this type.
Now please answer the highest value luras can earn if she choose in the best way.
Luras will take n lessons in sequence(in another word, to have a chance to skip xDDDD).
For every lesson, it has its own type and value to skip.
But the only thing to note here is that luras can't skip the same type lesson more than twice.
Which means if she have escaped the class type twice, she has to take all other lessons of this type.
Now please answer the highest value luras can earn if she choose in the best way.
Input
The first line is an integer T which indicates the case number.
And as for each case, the first line is an integer n which indicates the number of lessons luras will take in sequence.
Then there are n lines, for each line, there is a string consists of letters from 'a' to 'z' which is within the length of 10,
and there is also an integer which is the value of this lesson.
The string indicates the lesson type and the same string stands for the same lesson type.
It is guaranteed that——
T is about 1000
For 100% cases, 1 <= n <= 100,1 <= |s| <= 10, 1 <= v <= 1000
And as for each case, the first line is an integer n which indicates the number of lessons luras will take in sequence.
Then there are n lines, for each line, there is a string consists of letters from 'a' to 'z' which is within the length of 10,
and there is also an integer which is the value of this lesson.
The string indicates the lesson type and the same string stands for the same lesson type.
It is guaranteed that——
T is about 1000
For 100% cases, 1 <= n <= 100,1 <= |s| <= 10, 1 <= v <= 1000
Output
As for each case, you need to output a single line.
there should be 1 integer in the line which represents the highest value luras can earn if she choose in the best way.
there should be 1 integer in the line which represents the highest value luras can earn if she choose in the best way.
Sample Input
25english 1english 2english 3math 10cook 1002a 1a 2
Sample Output
1153
思路:map,结构体,水。
#include<stdio.h>
#include<iostream>#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
struct zz
{
char c[1111];
int num;
};
int f(zz x,zz y)
{
return x.num>y.num;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
struct zz a[1111];
int n;
scanf("%d",&n);
map<string,int>flag;
for(int i=0;i<n;i++)
{
scanf("%s%d",a[i].c,&a[i].num);
}
sort(a,a+n,f);
flag[a[0].c]=1;
int sum=a[0].num;
for(int i=1;i<n;i++)
{
if(flag[a[i].c]<2)
{
flag[a[i].c]++;
sum+=a[i].num;
}
}
printf("%d\n",sum);
}
return 0;
}
阅读全文
0 0
- HD6015 Skip the Class
- Skip the Class
- Skip the Class
- Skip the Class
- Skip the Class
- HDU6015 Skip the Class
- skip the class
- HDU6015 Skip the Class
- Skip the Class(6015)
- HDU-6015 Skip the class
- HUD 6015 Skip the Class
- HDU 6015 Skip the Class
- HDU 6015 Skip the Class
- HDU 6015 Skip the Class
- HDU 6015 Skip the Class
- hdu 6015 Skip the Class
- Skip the Class hdu AB
- HDU:6015 Skip the Class
- 关于JVM虚拟机
- BZOJ2091: [Poi2010]The Minima Game
- lombok 注解
- 数据结构---后序遍历
- NSOJ 我排第几个
- HD6015 Skip the Class
- Spark 简易入门教程(Java的微型Web框架)
- Java基础知识2
- swagger常用注解
- 阿里MNS服务:代码显示成功并可以得到消息id及其md5,手机却收不到短信
- Java内部类知识
- P1914 小书童——密码
- 关于linux(ubuntu)中直接右键复制粘贴与cp命令的区别
- [学习笔记]UE4--多线程的实现方式