HDU 6015 Skip the Class 优先队列 map的使用
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的使用的更多相关文章
- HDU 6015 Skip the Class
Skip the Class 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define l ...
- (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 ...
- HDU 1428 漫步校园 (BFS+优先队列+记忆化搜索)
题目地址:HDU 1428 先用BFS+优先队列求出全部点到机房的最短距离.然后用记忆化搜索去搜. 代码例如以下: #include <iostream> #include <str ...
- hdu 5437 Alisha’s Party 优先队列
Alisha’s Party Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_sh ...
- HDU 5884 Sort(二分+优先队列)
http://acm.hdu.edu.cn/showproblem.php?pid=5884 题意:有个屌丝设计了一个程序,每次可以将k个数组进行合并,代价为这k个数组总的长度之和.现在另外一个屌丝要 ...
- HDU 4974 Dracula and Ethan 优先队列
Dracula and Ethan Time Limit: 1 Sec Memory Limit: 256 MB Description Dragon is watching competition ...
- [HDU] 2094 产生冠军(拓扑排序+map)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2094 注意每组数据处理前,map要清空. #include<cstdio> #includ ...
- hdu 2757 Ocean Currents(优先队列+bfs)
小伙伴们真心被这道题惊呆了!刚开始是读题,题目都把小伙伴惊呆了,题目都读不懂! 在前面猴子小伙伴的帮助下,理解了一点点,又偷偷的在纸上写写画画,明白了题意! 后来,你懂的,果断拿下!在拿下的过程也经过 ...
- hdu 1263 水果 【二维map】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263 题目大意: Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ ...
随机推荐
- 逆袭之旅DAY16.东软实训.Oracle.索引
2018-07-12 14:44:27 四.索引1.创建索引手动创建:create index 索引名 on 表名(列名,[列名,...])create table employee(pno numb ...
- linux 用户/群组/权限
mv 原文件名 新文件名 #相当于重命名 查看文件内容相关命令 cat #查看文件全部内容 head - n #查看文件前n行内容(默认前十行) tail -n #查看文件后n行内容(默认后十行) t ...
- Kafka.net使用编程入门(二)
1.首先创建一个Topic,命令如下: kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partit ...
- CSS(三)--自定义标签
HTML代码 <body> <ul> <li>1</li> <li>2</li> </ul> </body&g ...
- 离线安装docker镜像
假如由于网络原因,需要在一台无网络的电脑上运行镜像,那么docker是支持的. 你需要做的主要有3步骤: 1:先从一个有网络的电脑下载docker镜像 sudo docker pull ubuntu ...
- Netty完成网络通信(二)
Netty是基于NIO的框架,完善了NIO的一些缺陷,因此可以用Netty替代NIO Netty实现通信步骤: 1.创建两个NIO线程组,一个专门用于网络事件处理(接受客户端的连接),另一个则进行网络 ...
- 前端之Bootstrap框架
一.Bootstrap介绍 Bootstrap是Twitter开源的基于HTML.CSS.JavaScript的前端框架. 它是为实现快速开发Web应用程序而设计的一套前端工具包. 它支持响应式布局, ...
- JAVA 中的MessageDigest类和Mac类的使用
MessageDigest 消息摘要 例子: MD5加密: try{ MessageDigest md5 = MessageDigest.getInstance("MD5"); m ...
- 安装ubuntu不能引导win7
台式机安装了ubuntu导致进不了win7了,2系统在同一硬盘. win7引导需要bootmgr和boot文件夹中的文件,2个东东在winows引导分区根目录下. 我的笔记本安装windows系统分区 ...
- zepto和jquery关于获取css样式的试用差别
例如 获取 html标签的 字体大小, zepto中方法:$("html").css( "font-size" ); jquery中方法:$("htm ...