HDU6015 Skip the Classmap
Posted tigerisland45
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU6015 Skip the Classmap相关的知识,希望对你有一定的参考价值。
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1637 Accepted Submission(s): 920
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.
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
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.
Sample Input
2
5
english 1
english 2
english 3
math 10
cook 100
2
a 1
a 2
Sample Output
115
3
Source
BestCoder Round #92
问题链接:HDU6015 Skip the Class
问题简述:(略)
问题分析:
????翘课有其价值,自然要翘价值最大的那2个。用map存储最大那2个,最后求一下和就可以了。
程序说明:(略)
参考链接:(略)
题记:(略)
AC的C语言程序如下:
/* HDU6015 Skip the Class */
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int main()
{
int t, n;
scanf("%d", &t);
while(t--) {
map<string, int> first, second;
char name[N + 1];
int len;
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
scanf("%s%d", name, &len);
if(first[name] < len) {
second[name] = first[name];
first[name] = len;
} else if(second[name] < len)
second[name] = len;
}
int ans = 0;
for(map<string, int>::iterator iter = first.begin(); iter != first.end(); iter++)
ans += iter->second;
for(map<string, int>::iterator iter = second.begin(); iter != second.end(); iter++)
ans += iter->second;
printf("%d
", ans);
}
return 0;
}
以上是关于HDU6015 Skip the Classmap的主要内容,如果未能解决你的问题,请参考以下文章
hdu 2019多校 Just Skip The Problem
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe