BestCoder Round #92

Skip the Class

 Accepts: 678
 Submissions: 1285
 Time Limit: 2000/1000 MS (Java/Others)
 Memory Limit: 65536/65536 K (Java/Others)
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
Copy

2
5
english 1
english 2
english 3
math 10
cook 100
2
a 1
a 2
Sample Output
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的更多相关文章

  1. LINQ系列:LINQ to SQL Take/Skip

    1. Take var expr = context.Products .Take(); var expr = (from p in context.Products select p) .Take( ...

  2. EntityFramework 7 OrderBy Skip Take-计算排序分页 SQL 翻译

    先解释一下这个标题的意思,OrderBy 在 Linq 语句中,我们经常使用,比如 OrderBy(b => b.BlogId) 就是对 BlogId 字段进行升序排序,这是针对一个字段的排序, ...

  3. 【记录】AutoMapper Project To OrderBy Skip Take 正确写法

    AutoMapper:Queryable Extensions 示例代码: using (var context = new orderEntities()) { return context.Ord ...

  4. Xcode插件安装 错选了Skip Bundle解决办法

    1.首先找到Xcode的UUID,在终端运行defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID ...

  5. ASP.NET泛型List的各种用法Skip、Take等

    List在.NET里面使用得非常频繁,但有好多人不了解它各种小用法.我就一直记不大住... asp.net中List的简单用法,例如: 1 2 3 4 5 6 7 List<int> li ...

  6. mongodb-$type、limit、skip、sort方法、索引、聚合

    一.$type操作符 $type操作符是基于BSON类型来检索集合中匹配的数据类型,并返回结果. MongoDB 中可以使用的类型如下表所示: 类型 数字 备注 Double 1   String 2 ...

  7. Xcode安装插件,错误选择了Skip Bundles,重新出现Load Bundles方法

    Xcode安装插件经常会遇到这样的问题,出现提示性选择,还是英文提示,所以没仔细看就习惯性的选择了右侧的按钮 点击了Skip Bundle,结果悲剧的发现,发现插件完全失效了,以后不管怎么打开Xcod ...

  8. [Android Pro] InputStream.skip方法的思考

    参考 : http://blog.csdn.net/gsyzhu/article/details/8102286 在java.io.InputStream类中定义了skip这个方法.在API中的描述如 ...

  9. 跳跃表Skip List的原理和实现

    >>二分查找和AVL树查找 二分查找要求元素可以随机访问,所以决定了需要把元素存储在连续内存.这样查找确实很快,但是插入和删除元素的时候,为了保证元素的有序性,就需要大量的移动元素了.如果 ...

  10. 转MongoDB 使用Skip和limit分页

    关于MongoDB 数据分页和排序 limit,skip用户的一些基础语句,介绍MongoDB 数据分页和排序实例方法. 使用Skip和limit可以如下做数据分页: Code: page1 = db ...

随机推荐

  1. 从注册表清理 IE10,IE11 用户代理字符串(UserAgent)中的垃圾信息

    某一天,我发现我的 IE User Agent 字符串里面竟然含有刷机大师.百度浏览器等许多垃圾,国货流氓见怪不怪了. 微软自家的.NET CLR也占据了一大片,看着也不爽. 决定清理一下,但是却没找 ...

  2. Springboot中Aspect实现切面(以记录日志为例)

    前言今天我们来说说spring中的切面Aspect,这是Spring的一大优势.面向切面编程往往让我们的开发更加低耦合,也大大减少了代码量,同时呢让我们更专注于业务模块的开发,把那些与业务无关的东西提 ...

  3. Golang LicenseServer授权服务器的设计 与 RSA 密钥对的应用

    //TODO 待写文章 目录: 1.为什么要写授权服务器  LicenseServer 2.授权服务器的设计思路 3.授权服务器所使用到的加密技术 1.为什么要写授权服务器 为了防止别人拿到二进制后, ...

  4. 修改编辑器为Markdown编辑器

    一直都在使用cnblogs的TinyMCE,不过感觉好久不更新,还是用Markdown吧,写多了Markdown 还真是受感染呢. 学习下吧,边学便用. 参考链接: 序列图 [简明版]有道云笔记Mar ...

  5. 如何将excel 数据库表结构生成powerdesign物理模型

    Option Explicit Dim mdl ' the current model Set mdl = ActiveModel If (mdl Is Nothing) Then MsgBox &q ...

  6. [DevExpress使用随笔]之NavBarControl控件(一)【转】

    https://blog.csdn.net/HXC_HUANG/article/details/78614092 NavBarControl是具有可扩展组的侧导航控件.一.在Winform窗口中拖入N ...

  7. SSE图像算法优化系列九:灵活运用SIMD指令16倍提升Sobel边缘检测的速度(4000*3000的24位图像时间由480ms降低到30ms)。

    这半年多时间,基本都在折腾一些基本的优化,有很多都是十几年前的技术了,从随大流的角度来考虑,研究这些东西在很多人看来是浪费时间了,即不能赚钱,也对工作能力提升无啥帮助.可我觉得人类所谓的幸福,可以分为 ...

  8. [C#] 将NLog输出到RichTextBox,并在运行时动态修改日志级别过滤

    作者: zyl910 一.缘由 NLog是一个很好用的日志类库.利用它,可以很方便的将日志输出到 调试器.文件 等目标,还支持输出到窗体界面中的RichTextBox等目标. 而且它还支持在运行时修改 ...

  9. MySQL在INSERT IGNORE未新增记录时避免AUTO_INCREMENT自增

    在MySQL5.7中做INSERT IGNORE时发现, 即使INSERT未成功执行, 表的自增主键却自动加1了, 在某些情况下需要避免这种行为. 需要修改的变量是 innodb_autoinc_lo ...

  10. 分析技术和方法论营销理论知识框架,营销方面4P、用户使用行为、STP,管理方面5W2H、逻辑树、金字塔、生命周期

    原文:五种分析框架:PEST.5W2H.逻辑树.4P.用户使用行为 最近在一点点的啃<谁说菜鸟不懂得数据分析>,相当慢,相当的费脑力,总之,真正的学习伴随着痛苦:) 最初拿到这本书的时候, ...