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

ubuntu打实时内核补丁教程以及安装后显卡驱动问题解决方法 在ubuntu20.04上安装成功,亲测有效 目录ubuntu打实时内核补丁教程1、下载实时内核2、解压和打补丁(patch)3、安装依赖和编译安装4、修改一些文件,便于之后切换内核5、重启电脑实时内核版本下安装nvidia显卡驱动的问题1、先切换回之前的内核(非实时)版本2、重装之前内核(非实时)版本下的显卡驱动3、切换回实时内核(按照上面的步骤)4、在实时内核下安装显卡驱动 ubuntu打实时内核补丁教程 安装目标系统:ubuntu20.04 电脑配置:i9,2080ti 1、下载实时内核 打开终端,输 阅读详情

题目戳我呀

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
题意:
每门课最多翘两次,翘掉最大价值的两次课,求翘掉课的最大的价值。
想法:
说是贪心,刚开始倒是看出来这是结构体和map的结合,结果没敲出来==
用struct来存储每次课的信息,map来标记次数。
下面这是某猪的代码↓

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
struct ss
{
    string les;
    int val;
};//一节课和对应的价值
int cmp(ss x, ss y)
{
    if(x.les == y.les)
    return x.val > y.val;//如果两节课是一门课,价值从大到小
    else
    return x.les > y.les;//如果不是一门课,字符串由大到小
}
int main()
{
    int t, n, ans;
    while(~scanf("%d",&t))
    {
        while(t--)
        {
            map<string, int> qq;//一门课和次数
            ss f[105];
            ans = 0;
            scanf("%d",&n);
            for(int i = 0; i < n; ++i)
                cin >> f[i].les >> f[i].val;
            sort(f, f+n, cmp);
            for(int i = 0; i < n; ++i)
            {
                qq[f[i].les]++;//每门课对应的次数增加
                if(qq[f[i].les] <= 2) ans += f[i].val;
            }
            cout << ans << endl;
        }
    }
    return 0;
}

另一种用两个map的做法 (?我当时怎么会觉得这种更简单呢

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
map<string,int>map1,map2;
int main()
{
    int t;
    string str;
    int val;
    cin>>t;
    while(t--)
    {
        map1.clear();
        map2.clear();
        int n;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>str>>val;
            if(map1[str]<val)
            {
                map2[str]=map1[str];
                map1[str]=val;
            }
            else if(map2[str]<val)
            {
                map2[str]=val;
            }
        }
        int ans=0;
        map<string ,int>::iterator it;
        for(it=map1.begin();it!=map1.end();it++)
        {
            ans+=it->second;
        }
        for(it=map2.begin();it!=map2.end();it++)
        {
            ans+=it->second;
        }
        cout<<ans<<endl;
    }
    return 0;
}

另外,G++是c++的编译器,g++是编译器,c++是语言。
这两份代码都该在g++下交才对,结果我个辣鸡用c++ ce了一下午到怀疑人生:)

聚类分析之——Kmeans算法(一) 原创地址:http://www.toutiao.com/i6399454239554273794/ 聚类分析是一种静态数据分析方法,常被用于数据挖掘、机器学习、模式识别等领域,聚类是一种无监督式的学习方法。它是在未知样本类别的情况下,通过计算样本彼此间的距离(欧式距离,马式距离,汉明距离,余弦距离等)来估计样本所属类别。从结构性来划分,聚类方法分为自上而下和自下而上两种方法。聚类的算法有很多 阅读详情

相关推荐

避坑指南:Qgis等时圈分析中ORS插件Key申请与参数设置的常见错误

本文详细解析了QGIS等时圈分析中ORS插件从API密钥申请到参数优化的全流程避坑指南。针对密钥激活、出行模式选择、时空参数设置等七个高频故障点,提供了实用的调试方案和优化技巧,帮助用户高效完成空间可达性分析。

weixin_42546508的博客 310

hdu 6015 Skip the Class

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

aidiao7379的博客 202

高通Camx架构调试不求人:手把手教你开UMD/KMD Log与Dump图像(附离线Log合成脚本)

本文详细介绍了高通Camx架构的调试方法,包括UMD/KMD Log的精准配置与图像Dump技术,帮助工程师快速定位移动影像系统中的问题。通过实战案例和自动化脚本,提升调试效率,适用于图像色彩异常、帧率波动等常见问题的诊断与解决。

weixin_30516243的博客 258

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

Python的WNTR库---基于供水网络

WNTR使用小结(一) 本人最近主要再做设施网络的内容,主要聚焦供水管网(water distribution network,WDN),在做实验中主要用的包为WNTR,下载连接: 链接: WNTR.最好安装最新版本 如果有做这方面研究的小伙伴们需要测试数据可以直接从WNTR实例数据中下载,其中提供了四种规模大小的管网,格式为.inp,可以搭配Epanet使用。如果需要更多示例数据可私信我! 以下内容全部为本人自己探索的小心得,希望能给你带来一点点帮助,如果不够详尽可以自行参阅官方文档:链接: 官方文档.

pushhy的博客 4941

from pointnet2_ops import pointnet2_utils 安装过程

pointnet2_ops

goodgoodstudy___的博客 8370

HDU6015(思维题)

题目意思就是给你一颗树, Bob可以在树上染色,就是选择一个点,并且将其周围的点涂黑 Alice可以将树上的一个点涂白 Bob还可以做一个操作,就是剪枝,剪枝之后影响的只是涂黑的操作,就是比如我涂一个点本来可以把周围的点全部染黑的,现在就是减掉的部分就不能染黑了 最后,当树全部都被涂完的话,我们就找树上有没有白点,如果有那么Alice赢了,否则就是Bob赢 那么题解就是判断,分m

HZAU_ZXB的博客 479

TCNOpen实现TRDP通信协议(源码编译运行测试)

概述 本文介绍了通过TCNOpen开源源码实现TRDP通信,包括源码下载,开发环境搭建,编译运行,测试。 Linux环境下编译运行TRDP (一) 下载CANOpen源码。 下载地址:https://sourceforge.net/p/tcnopen/trdp/HEAD/tree/ (二) 源码编译 下载源码解压过后,在根目录文件readme-makefile.txt有介绍源码的配置和编译方法。 在trdp/config目录下可以看到包含在linux环境下的编译配置文件LINUX_config;执行”m

fengweibo112的博客 9650

hdu6015

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

creatorx的博客 461

骑砍Ⅱ霸主MOD开发(8)-骨骼动画

基于四向攻击设计的动作参数,包括动作仰角,环视方向,物理碰撞检测等参数通过XML进行配置.配置文件:ModuleData\combat_parameters.xml。为Agent定制化设计的骨骼动画切片为动作ActionSet,通过action_types.xml和action_sets.xml进行配置.action_types.xml和action_sets.xml全局初始化后会进行缓存,在内存中保留每个ActionType的唯一索引。自定义骨骼动画会进行动画数据缓存,根据持续时长,帧数量进行统计计算.

骑砍战团&霸主MOD开发 1109

【原理图PCB专题】案例:双排0.5mm间距座子转单排0.5mm间距座子Layout方案分析

本文提供一种分析思路,并通过实际案例来进行Layout方案分析的讲解。

一点硬件 459

HDU 6015

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

juanlansexuehua的博客 300

EtherCAT主站SOEM -- 15 -- CIA402伺服驱动器子协议

以上就是EtherCAT主站SOEM – 15 – CIA402伺服驱动器子协议的内容。有不明白的地方欢迎留言;有建议欢迎留言,我后面编写文档好改进。创作不容,如果文档对您有帮助,记得给个赞。

常驻客栈的博客--嵌入式EtherCAT 2743

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

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

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

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...

[HDU] 6015 - Skip the Class - 贪心 + STL

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

十七是只大奶牛 510

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

HDU 6015 Skip the Class(map用法)

题目链接:http://hdu.hustoj.com/showproblem.php?pid=6015Problem DescriptionFinally term begins. luras loves school so much as she could skip the class happily again.(wtf?)Luras will take n lessons in seque...

baodream的博客 303

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【水题】

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

mengxiang000000 763

2020 HDU多校 第四场 02-Blow up the Enemy(贪心 + Map)

题目链接: 02-Blow up the Enemy Description 题意:给出n把武器的伤害值和使用间隔,求选中互相攻击必胜的概率 Zhang3 is playing a shooting game with Father. In the game there are two players trying to kill each other to win the game. The game provides n weapons, each has two properties: Damage

Carizy的博客 290

poj The Unique MST 次小生成树(入门级)

The Unique MST Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 30039 Accepted: 10754 Description Given a connected undirected graph, tell if its minimum sp

他说少年如歌 943

HDU6015 Skip the Class (Map)

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

blanKey的博客 628

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 eve

ac_blood的博客 729

HDU 6015 Skip the Class

Skip the Class 题目链接:传送门 这个题目真是恨死了,早就知道C++中很多容器能用到,却没有好好学。终于弄懂了用map写出来了。 解题思路:对于每一种类型的课程,我们只会选择翘掉 翘课价值最大的前2节课。 #include #include using namespace std; int main() { string str; int val; map m1,

Singular__point的博客 457

HDU6015 Skip the Class

Skip the Class                                                                            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

moonlight的博客 423

HDU 3348 coins【贪心】

题目来戳呀Problem Description“Yakexi, this is the best age!” Dong MW works hard and get high pay, he has many 1 Jiao and 5 Jiao banknotes(纸币), some day he went to a bank and changes part of his money into 1

卡西莫多 575
上一篇: HDU 1789 Doing Homework again【贪心】
下一篇: HDU 6016 Count the Sheep【思维】
皮科克
博客等级 码龄10年 15粉丝 87原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值