HDU 6015 Skip the Class(map用法)

AXI Timer IP核使用说明 AXI Timer是提供定时技术功能的集成IP核,具有时间生成、事件捕获、产生PWM波以及产生中断的功能,下面具体讲述Timer IP核的使用说明。 阅读详情

题目链接:http://hdu.hustoj.com/showproblem.php?pid=6015

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


题意:给定n门课名字和逃这门课的价值,相同课程最多逃2次,问逃课价值最大值

思路:贪心,逃价值大的课,用map记录一下逃了几次,初学map,尝试用迭代器写的,大家也可以用数组写,方便一点

代码:

#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<map>

using namespace std;

#define FOU(i,x,y) for(int i=x;i<=y;i++)
#define FOD(i,x,y) for(int i=x;i>=y;i--)
#define MEM(a,val) memset(a,val,sizeof(a))
#define PI acos(-1.0)

const double EXP = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll MINF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
const int N = 1e6+5;

struct node
{
	string s;
	int val;	
}a[105];

bool cmp(node A,node B)
{
	return A.val>B.val;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    std::ios::sync_with_stdio(false);
    int n,t;
    map<string,int>mp;
    cin>>t;
	while(t--)
    {
    	cin>>n;
    	mp.clear();
    	for(int i=1;i<=n;i++)
    	{
    		cin>>a[i].s>>a[i].val;
    		mp[a[i].s]=0;   
		}
    	sort(a+1,a+1+n,cmp);
    	int ans=0;
    	for(int i=1;i<=n;i++)
    	{
    		map<string,int>::iterator iter = mp.find(a[i].s);
			if(iter->second>=2)
    			continue;
    		else
    		{
    			iter->second++;
    			ans+=a[i].val;
			}
		}
		cout<<ans<<endl; 
	}
    return 0;
}


30天入门 SAP BTP 开发系列之一:SAP 开发顾问为什么要学习 SAP BTP 开发?能带来哪些收获? 国内 SAP 开发顾问们的微信朋友圈,最近可能都被 SAP 和阿里这两家巨头宣布合作的重磅消息刷屏了吧。近日,德国软件巨头SAP SE与中国电商巨头阿里巴巴集团宣布建立战略合作伙伴关系。根据协议,阿里巴巴集团将利用 SAP Cloud ERP Private 强化企业基础设施,并采用联合上市策略为全球客户创造卓越价值。阿里巴巴将集成 SAP Business Suite,以简化系统维护与升级流程,并实现 AI 功能与核心业务流程的无缝整合。 阅读详情

相关推荐

在ubuntu20.04上配置VINS_Fusion(亲测有效,一应俱全)

最近在做科研训练的时候配置了HKUST-Aerial-Robotics实验室的VINS_Fusion代码项目,经历了一些编译报错的问题,在网上查找的时候博客内容良莠不齐,且实质针对性意见不多,于是在此记录下自己配置期间遇到的一些共性问题,留作自己日后参考和大家的交流学习。

wyr1849089774的博客 8277

hdu 6015 Skip the Class

  题目链接:HDU 6015   一开始读题有点懵,不知道是什么意思,不过后来想到既然是 BestCoder 的题,那么就用它的思维去理解,大胆 yy 题意即可。   题意大概就是说有 n 们课程,Luras 每逃一门都能得到相应的 value,但同一们课程(前面的字符串完全相同)最多只能逃两次,逃两次后就必须去上这们课了,也就不能再获得这们课的后续的 value 了,问Lura...

aidiao7379的博客 202

GEE AI: 利用 Satellite Embedding 语义搜索快速识别研究区目标斑块

摘要 本文介绍了一种基于Google Earth Engine的遥感语义搜索技术,利用Satellite Embedding数据集快速识别目标地物。该方法通过将光谱信息转化为高维向量,在武汉市的案例中展示了如何:1)定义研究区和样本点;2)加载预处理的Embedding数据;3)计算向量相似度;4)结合面积过滤优化结果。相比传统监督分类,该技术具有响应快速(无需模型训练)、抗季节干扰和精准界定等优势,特别适用于森林碳储量监测和土地利用检测等应用场景。文中提供了完整的GEE代码实现流程,包括样本定义、相似度计

此星光明博客 628

Skip the Class

Skip the Class Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 123    Accepted Submission(s): 73 Problem Description Finally term begin

wanghandou的博客 900

DDR ECC错误注入与寄存器配置实战指南

本文详细介绍了DDR ECC错误注入的核心价值与实战操作指南,包括通过FI_Dx和FI_ECC寄存器注入数据与ECC错误的方法。文章提供了环境准备、寄存器配置、错误检测及系统可靠性测试策略,帮助开发者验证内存系统的纠错能力和可靠性,提升硬件开发的稳定性与效率。

nnn11的博客 1109

EBS开发_离散工单创建API

--以下代码于20171213在TONY环境中实现 DECLARE     l_iface_rec    wip.wip_job_schedule_interface%ROWTYPE; --工单任务接口表     l_group_id     NUMBER;     l_returnstatus VARCHAR2(40);     l_errormsg     VARCHAR2(2000

蜗牛先生快跑的博客 2601

HDU 6015-Skip the Class(模拟-结构体排序)

Skip the Class    Accepts: 678    Submissions: 1285  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) 问题描述 终于又开学啦。呃喵最喜欢的就是开学了,因为这样她又可以愉快地翘课了(啊?) 呃喵接

Some. 749

别再只改config了!YOLO/RT-DETR多通道输入实战:数据集结构、多卡训练与参数优先级避坑指南

本文详细解析了YOLO/RT-DETR模型在多通道输入(如8通道多光谱图像)中的实战应用,涵盖数据集结构优化、数据加载器改造、模型参数调优及多卡训练配置。针对常见的多通道输入报错问题,提供了系统的解决方案和性能优化技巧,帮助开发者高效实现非标准数据格式的适配与训练。

weixin_30955617的博客 406

Hdu 6015 Skip the Class【水题】

Skip the Class    Accepts: 678    Submissions: 1285  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) 问题描述 终于又开学啦。呃喵最喜欢的就是开学了,因为这样她又可以愉快地翘课了(啊?) 呃喵接

mengxiang000000 763

【数据集】CMIP6气候模式数据下载

简介CMIP6及其气候模式数据下载

WW、forever的博客 9368

基于知识图谱的档案智慧问答系统:构建智能化档案管理与知识服务新范式

基于知识图谱的档案智慧问答系统是档案管理领域的一次重要创新,它通过将档案数据转化为结构化的知识图谱,并结合自然语言处理和智能问答技术,实现了档案信息的智能化管理与服务。该系统不仅能够提升档案管理的效率,还能为用户提供更全面、更便捷的知识服务,具有广泛的应用前景和深远的社会意义。未来,随着技术的不断进步和应用场景的不断扩展,基于知识图谱的档案智慧问答系统将在更多领域发挥其价值,为档案管理领域的智能化转型提供强有力的支持。

qq_62634009的博客 1582

HDU——6015 Skip the Class

题目链接: 一个sort排序 但是要注意是否出现了大于等于三次 所以需要map把string对应到int计次数 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cstring&gt; #include&lt;cmath&gt; #include&lt;algorithm&gt; #include&lt;queue&g...

ZMST的博客 391

一张图讲透银行个人外汇业务逻辑和实操

个人外汇业务主要分为结售汇和外币兑换两类,前者满足日常跨境需求,后者因投机属性多数银行已暂停。业务核心是利用汇率波动实现货币兑换,满足支付或投资需求。交易涉及客户分类、主流币种、多种渠道和汇率计算规则,需区分直接/间接标价法判断汇率走势。银行通过"货币兑换"科目核算损益,采用期末折算确认盈亏。监管要求包括5万美元年度额度、合法渠道、真实性原则及大额申报等。随着跨境金融数字化发展,掌握基础逻辑和合规要求是安全参与外汇业务的关键。

银行信息系统应用架构详解 301

HDU6015 Skip the Class【map】

Skip the Class Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1637 Accepted Submission(s): 920 Problem Description Finally term begins. lur...

海岛Blog 511

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

HDU6015 Skip the Class (Map)

传送门 题目大意: 终于又开学啦。呃喵最喜欢的就是开学了,因为这样她又可以愉快地翘课了(啊?) 呃喵接下来有n节课程需要上(换句话说,可以翘。) 每节课程有相应的课程类型与课程翘课价值。 有一点需要注意的是,呃喵不可以翘同一类课程超过两次,就是如果这类课已经翘了两次,接下来就一定要上。 问你在这个条件下,呃喵可以获得的最大翘课价值。 解题思路:直接使用map来解决,方便快

blanKey的博客 628

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

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): 837    Accepted Submission(s): 484 Problem Description Finally term

LiQiyao的博客 410

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

HDU 6015 Skip the Class【BestCoder Round #92】map

开学第一场BC。 翘课的话肯定是翘价值最大的那两节。 注意:上课的顺序就是输入的顺序,所以用map保存每门课的最大价值和第二大价值,然后求和就可以了。

AC_Dreameng 854

HDU 6015 Skip the Class【贪心】【map】

题目戳我呀 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 ...

卡西莫多 716

HDU 6015 Skip the Class 优先队列 map的使用

Skip the ClassTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1028 Accepted Submission(s): 599Problem Description Finally term begins. lura

一个小孩的自我踌躇 387

HDU:6015 Skip the Class(map)

Skip the Class    Accepts: 678    Submissions: 1285  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) 问题描述 终于又开学啦。呃喵最喜欢的就是开学了,因为这样她又可以愉快地翘课了(啊?) 呃喵接

zugofn的博客 320

【HDU-oj】-6015-Skip the Class(map string vector)

Skip the Class    Accepts: 678    Submissions: 1285  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) 问题描述 终于又开学啦。呃喵最喜欢的就是开学了,因为这样她又可以愉快地翘课了(啊?) 呃喵接

Bear1998的博客 500

HDU-6015-Skip the Class(STL:map)

Skip the Class 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

lhc----- 233

HDU 6015 Skip the Class

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6015 题意:n个例子,s是课程名,v是每节课的价值,每种课最多可以翘2次,问能获得的最大的翘课价值是多少 思路:HahsMap里面套一个ArrayList进行模拟就行了 AC代码: import java.util.ArrayList; import java.util.Arrays; imp

Java识堂,一个有干货的微信公众号 600

HDU:6015 Skip the Class

Skip the Class Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 775    Accepted Submission(s): 448 题目链接 Problem Description Finally

温姑娘的博客 1357

【STL】hdu 6015 Skip the Class

map....

Gzbgreat的博客 290

HDU-6015 Skip the Class

Skip the Class 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

Rainbow__sea的博客 254
上一篇: C++的STL容器之关联性容器set、multiset、map、multimap
下一篇: hdu 4989 Summary(set)
baodream
博客等级 码龄10年 55粉丝 239原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值