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 ...
随机推荐
- Go语言之高级篇beego框架之日志收集系统
一.日志收集系统架构设计 图1 图2 二.开发环境 1.安装jdk jdk-8u51-windows-x64.exe 安装目录:C:\Program Files\jdk8 2.安装zookeeper ...
- Geek/Git中文怎么读
Geek怎么读 英[gi:k] = gay客 = 给客 Git怎么读 英[gɪt] = gay 特 = 给特 Flux怎么读 英[flʌks] = 佛拉克斯 Redux怎么读 英[ri:'dʌks] ...
- SuperObject生成示例
var jo,jEntity,jSubEntity: ISuperObject; jaOrder,jaEntity,jaSubEntity: ISuperObject; i,j,entityCount ...
- selenium面试题总结
2017年7月17日更新:已经更新部分答案 答案链接 今天有同学问到seleinum面试的时候会问到的问题,随便想了想,暂时纪录一下.欢迎大家在评论中提供更多问题. 去哪儿的面试题 selenium中 ...
- Mathematica绘制曲面交线方法
新引入的SliceContourPlot不错 SliceContourPlot3D[y, (1.7 x^2 + y/3 + 0.6 z^2) (1.7 (x - 2)^2 + y/3 + 0.6 z^ ...
- Navicat Premium 12破解方法
来源网址:https://www.jianshu.com/p/42a33b0dda9c 1.按步骤安装Navicat Premium,如果没有可以去官网下载:http://www.navicat.co ...
- idea 配置普通web项目
跟配置maven项目类似 idea 配置 maven 项目 注意点 1.取消第一步 2.添加依赖的时候,如果lib下没有servlet依赖包,可以加个tomcat环境进来编译 ps:在artifact ...
- Centos7下安装Oracle11g r2图形化界面数据库
我的centos7是在VMware下安装的,安装Oracle安装了好久好久,最开始的时候在网上找的两个文章,按照步骤装,有一篇写着装的时候有灰色的竖线,直接按space键或者鼠标右键closed关闭掉 ...
- redhat 7.5 更换 yum源
因为 redhat 的 yum 是收费,所以需要换成 Centos 的 yum 才可以 首先,卸载 redhat 的 yum 软件 sudo rpm -qa|grep yum 其次,下载 Centos ...
- 数据仓库:Mysql大量数据快速导出
背景 写这篇文章主要是介绍一下我做数据仓库ETL同步的过程中遇到的一些有意思的内容和提升程序运行效率的过程. 关系型数据库: 项目初期:游戏的运营数据比较轻量,相关的运营数据是通过Java后台程序聚合 ...