Skip the Class

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 1028 Accepted Submission(s): 599

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

#include <iostream>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm> using namespace std;
typedef long long ll;
struct cla{
char na[15];
int val;
}a[105];
bool cmp(cla a,cla b) {
return a.val>b.val;
}
int main() {
int t;
map<string,int> mp;
cin>>t;
while(t--) {
mp.clear();
int n;
cin>>n;
ll sum=0;
for(int i=0;i<n;i++) {
scanf("%s%d",a[i].na,&a[i].val);
}
sort(a,a+n,cmp);
for(int i=0;i<n;i++) {
if(mp[a[i].na]==2) continue;
else mp[a[i].na]++;
sum += a[i].val;
}
printf("%lld\n",sum);
}
return 0;
}

HDU 6015 Skip the Class 优先队列 map的使用的更多相关文章

  1. HDU 6015 Skip the Class

    Skip the Class 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define l ...

  2. (bc 1001) hdu 6015 skip the class

    Skip the Class Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) T ...

  3. HDU 1428 漫步校园 (BFS+优先队列+记忆化搜索)

    题目地址:HDU 1428 先用BFS+优先队列求出全部点到机房的最短距离.然后用记忆化搜索去搜. 代码例如以下: #include <iostream> #include <str ...

  4. hdu 5437 Alisha’s Party 优先队列

    Alisha’s Party Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_sh ...

  5. HDU 5884 Sort(二分+优先队列)

    http://acm.hdu.edu.cn/showproblem.php?pid=5884 题意:有个屌丝设计了一个程序,每次可以将k个数组进行合并,代价为这k个数组总的长度之和.现在另外一个屌丝要 ...

  6. HDU 4974 Dracula and Ethan 优先队列

    Dracula and Ethan Time Limit: 1 Sec  Memory Limit: 256 MB Description Dragon is watching competition ...

  7. [HDU] 2094 产生冠军(拓扑排序+map)

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2094 注意每组数据处理前,map要清空. #include<cstdio> #includ ...

  8. hdu 2757 Ocean Currents(优先队列+bfs)

    小伙伴们真心被这道题惊呆了!刚开始是读题,题目都把小伙伴惊呆了,题目都读不懂! 在前面猴子小伙伴的帮助下,理解了一点点,又偷偷的在纸上写写画画,明白了题意! 后来,你懂的,果断拿下!在拿下的过程也经过 ...

  9. hdu 1263 水果 【二维map】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263 题目大意: Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ ...

随机推荐

  1. vue 列表选中 v-for class

    地址: https://jsfiddle.net/50wL7mdz/96567/ 列表循环,默认选择 样式控制 <script src="https://unpkg.com/vue&q ...

  2. python2x 与 python3x 区别

    python2.x 与 python3.x 的区别: 1. python2.x 的源码编码不规范,源码重复较多:python3.x 的源码编码规范,清晰.优美.简单 2. python2.x的默认字符 ...

  3. ES6中的Promise.resolve()的作用

    var foo = { then: (resolve, reject) => resolve('foo') }; var resolved = Promise.resolve(foo); 相当于 ...

  4. windows 执行bat脚本

    bat脚本中运行另外一个bat脚本 call 命令 call1.bat内容如下 echo running call1 call2.bat内容如下 @echo off echo start call c ...

  5. Vue笔记:使用 vuex 管理应用状态

    如果你在使用 vue.js , 那么我想你可能会对 vue 组件之间的通信感到崩溃 . 我在使用基于 vue.js 2.0 的UI框架 ElementUI 开发网站的时候 , 就遇到了这种问题 : 一 ...

  6. JAVA设计模式(一)单例模式

    单例设计模式 Singleton是一种创建型模式,指某个类采用Singleton模式,则在这个类被创建后,只可能产生一个实例供外部访问,并且提供一个全局的访问点. 核心知识点如下: (1) 将采用单例 ...

  7. Suffix树,后缀树

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  8. C++标准异常概述

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  9. VSTO:使用C#开发Excel、Word【6】

    Office主互操作程序集(PIA)在了解如何构建Office解决方案之前,您需要更详细地了解在.NET中与Office对象模型通信的托管程序集.用于与Office通话的托管程序集称为Office主互 ...

  10. UFT测试本地应用程序登陆小实例(描述性编程)

    Dim username,password Dim casecount,i Dim currentid DataTable.ImportSheet ,"Action1" casec ...