Skip the Class
BestCoder Round #92
Skip the Class
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.
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
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.
2
5
english 1
english 2
english 3
math 10
cook 100
2
a 1
a 2
115
3
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#define FOR(i,x,n) for(int i=x;i<n;i++)
#define ll long long int
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAX_N 50005 using namespace std; struct node{
char course[];
int v;
}; node no[]; int compar(char a[],char b[]){
int aa=strcmp(a,b);
if(aa>){
return ;
}
return ;
} int compar2(char a[],char b[]){
int aa=strcmp(a,b);
if(aa==){
return ;
}
return ;
} int cmp(node a,node b){
return compar(a.course,b.course)||compar2(a.course,b.course)&&a.v>b.v;
} int main()
{
//freopen("data.txt", "r", stdin);
//freopen("data.out", "w", stdout);
int T;
int n;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
FOR(i,,n){
scanf("%s ",&no[i].course);
scanf("%d",&no[i].v);
}
sort(no,no+n,cmp);
int cou;
int sum=;
sum+=no[].v;
cou=;
FOR(i,,n){
if(compar2(no[i].course,no[i-].course)){
if(cou==){
sum+=no[i].v;
cou++;
}else{
continue;
}
}else{
sum+=no[i].v;
cou=;
}
}
printf("%d\n",sum); }
//fclose(stdin);
//fclose(stdout);
return ;
}
Skip the Class的更多相关文章
- LINQ系列:LINQ to SQL Take/Skip
1. Take var expr = context.Products .Take(); var expr = (from p in context.Products select p) .Take( ...
- EntityFramework 7 OrderBy Skip Take-计算排序分页 SQL 翻译
先解释一下这个标题的意思,OrderBy 在 Linq 语句中,我们经常使用,比如 OrderBy(b => b.BlogId) 就是对 BlogId 字段进行升序排序,这是针对一个字段的排序, ...
- 【记录】AutoMapper Project To OrderBy Skip Take 正确写法
AutoMapper:Queryable Extensions 示例代码: using (var context = new orderEntities()) { return context.Ord ...
- Xcode插件安装 错选了Skip Bundle解决办法
1.首先找到Xcode的UUID,在终端运行defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID ...
- ASP.NET泛型List的各种用法Skip、Take等
List在.NET里面使用得非常频繁,但有好多人不了解它各种小用法.我就一直记不大住... asp.net中List的简单用法,例如: 1 2 3 4 5 6 7 List<int> li ...
- mongodb-$type、limit、skip、sort方法、索引、聚合
一.$type操作符 $type操作符是基于BSON类型来检索集合中匹配的数据类型,并返回结果. MongoDB 中可以使用的类型如下表所示: 类型 数字 备注 Double 1 String 2 ...
- Xcode安装插件,错误选择了Skip Bundles,重新出现Load Bundles方法
Xcode安装插件经常会遇到这样的问题,出现提示性选择,还是英文提示,所以没仔细看就习惯性的选择了右侧的按钮 点击了Skip Bundle,结果悲剧的发现,发现插件完全失效了,以后不管怎么打开Xcod ...
- [Android Pro] InputStream.skip方法的思考
参考 : http://blog.csdn.net/gsyzhu/article/details/8102286 在java.io.InputStream类中定义了skip这个方法.在API中的描述如 ...
- 跳跃表Skip List的原理和实现
>>二分查找和AVL树查找 二分查找要求元素可以随机访问,所以决定了需要把元素存储在连续内存.这样查找确实很快,但是插入和删除元素的时候,为了保证元素的有序性,就需要大量的移动元素了.如果 ...
- 转MongoDB 使用Skip和limit分页
关于MongoDB 数据分页和排序 limit,skip用户的一些基础语句,介绍MongoDB 数据分页和排序实例方法. 使用Skip和limit可以如下做数据分页: Code: page1 = db ...
随机推荐
- Python3 与 NetCore 基础语法对比(String专栏)
汇总系列:https://www.cnblogs.com/dunitian/p/4822808.html#ai Jupyter排版:https://www.cnblogs.com/dunitian/p ...
- SOLDI原则之DIP:依赖倒置原则
本篇介绍软件设计原则之一DIP:依赖倒置原则.很多知识回头来看会有新的理解.看到一句话,一段文字,一个观点有了新的理解,醍醐灌顶的感觉.这种感觉像是一种惊喜.古语说:温故而知新. DIP:依赖倒置原则 ...
- 中国大学MOOC-陈越、何钦铭-数据结构-2017春
中国大学MOOC-陈越.何钦铭-数据结构-2017春 学习地址 详细学习内容 Github记录地址 欢迎fork和star,有惊喜值得学习! 参考学习笔记 参考AC代码 数据结构和算法学习笔记 学习内 ...
- Android开发中常见的设计模式 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- [Canvas]空战游戏进阶 增加己方子弹管理类
点此下载源码,可用Chrome打开观看. 图例: 代码: <!DOCTYPE html> <html lang="utf-8"> <meta http ...
- CSS 小技巧(不定时更新)
1.Web 文本中的省略号 在Web开发中,对于一种情况很常见.那就是,文本太长,而放置文本的容器不够长,而我们又不想让文本换行,所以,我们想使用省略号来解决这个问题.在今天HTML的标准中并没有相关 ...
- SSE图像算法优化系列二十六:和时间赛跑之优化高斯金字塔建立的计算过程。
图像金字塔技术在很多层面上都有着广泛的应用,很多开源的工具也都有对他们的建立写了专门的函数,比如IPP,比如OpenCV等等,这方面的理论文章特别多,我不需要赘述,但是我发现大部多分开源的代码的实现都 ...
- CentOS7通过rsync+crontab实现两台服务器文件同步
centos7系统中已经默认安装rsync 1:主服务器配置 (1)修改rsyncd.conf 配置文件 [root@localhost app]# vi /etc/rsyncd.conf motd ...
- jquery核心
1.找到所有 p 元素,并且这些元素都必须是 div 元素的子元素 $("div > p"); 2.设置页面背景色 $(document.body).css("ba ...
- Linux学习必备
17,继往开来 实践是检验真理的唯一标准! ---运维技术组----mvpbang #开源代码 https://github.com/ #目前最受欢迎的 https://gitee.com/ ...