NEFU 1265 (贪心+优先队列)

科技中介服务机构想要提升服务效率,需要哪些数智工具支持?.docx 科技中介服务机构想要提升服务效率,需要哪些数智工具支持? 立即下载

最高奖励

Problem:1265
Time Limit:1000ms
Memory Limit:65535K

Description

有N个任务,每个任务有一个最晚结束时间以及一个对应的奖励。在结束时间之前完成该任务,就可以获得对应的奖励。完成每一个任务所需的时间都是1个单位时间。有时候完成所有任务是不可能的,因为时间上可能会有冲突,这需要你来取舍。求能够获得的最高奖励。

Input

输入包含多组数据。
每组数据第1行:一个数N,表示任务的数量(2 <= N <= 50000)
第2 - N + 1行,每行2个数,中间用空格分隔,表示任务的最晚结束时间E[i]以及对应的奖励W[i]。(1 <= E[i] <= 10^9,1 <= W[i] <= 10^9)

Output

输出能够获得的最高奖励。

Sample Input

7
4 20
2 60
4 70
3 40
1 30
4 50
6 10

Sample Output

230

题意:中文题。

思路:因为过了截止时间,就不能再继续做任务了。所以按照时间的升序排列,从后往前遍历。将任务依次放入优先队列中。

如果两个任务之间的截止时间不相同,这时候在优先队列里面的都是满足可以做任务的要求。取出队首相加就行了。

代码:

[cpp]  view plain  copy
  1. #include <iostream>  
  2. #include <cstdio>  
  3. #include <cstring>  
  4. #include <algorithm>  
  5. #include <queue>  
  6. using namespace std;  
  7. struct node  
  8. {  
  9.     int e,w;  
  10.     friend bool operator <(node a,node b)  
  11.     {  
  12.         return a.w<b.w;  
  13.     }  
  14. }q[50005];  
  15. bool cmp(node a,node b)  
  16. {  
  17.     if(a.e!=b.e)  
  18.         return a.e<b.e;  
  19.     return a.w<b.w;  
  20. }  
  21. priority_queue<node> que;  
  22. int main()  
  23. {  
  24.     int n;  
  25.     while(~scanf("%d",&n))  
  26.     {  
  27.         while(!que.empty()) que.pop();  
  28.         long long ans=0;  
  29.         for(int i=1;i<=n;i++)  
  30.         {  
  31.             scanf("%d%d",&q[i].e,&q[i].w);  
  32.         }  
  33.         sort(q+1,q+n+1,cmp);  
  34.         q[0].e=0;  
  35.         for(int i=n;i>=1;i--)  
  36.         {  
  37.             que.push(q[i]);  
  38.             if(q[i].e!=q[i-1].e)  
  39.             {  
  40.                 for(int j=1;j<=q[i].e-q[i-1].e;j++)  
  41.                 {  
  42.                     if(!que.empty())  
  43.                     {  
  44.                         ans+=(long long)que.top().w;  
  45.                         que.pop();  
  46.                     }  
  47.                     else break;  
  48.                 }  
  49.             }  
  50.         }  
  51.         printf("%lld\n",ans);  
  52.     }  
  53.     return 0;  
  54. }  
usb 扩容盘检测修复工具源码,编译产物 立即下载

相关推荐

本地如何安装midscene.js运行环境

手把手教你本地安装midscene.js运行环境

实践助梦想成长 2608

NEFU 617 贪心

点击打开链接 好多考试 Problem:617 Time Limit:1000ms Memory Limit:65536K Description 期末到了,一学期基本上都没上课的ACMer,们要开始预习了… 每一科的考试时间也都出来了,每一科的学分也都知道,如果没预习挂掉的话可是要扣学分的… 假设每

DT2131 409

DMA engine initialization failed rk3568的原因及解决方案

刚开始调试 switch 芯片的时候由于rgmii 时钟是output , rk3568的 GMAC 需要 switch 芯片提供 125M的时钟,如果没有这个时钟就会初始化失败,进入文件系统后 ethx 不会出现(当然,如果屏蔽掉这里ethx 会出现,但是引发更多的问题,笔者在这块耍小聪明,导致耗费了近一个月时间,把网络这块整个查了一遍 -----)dma 软复位是在进入文件系统后,网络系统启动的时候,我想如果在这个之前只要提供合适的时钟那么就是可以的,那么------以上是官方的文档说明。

Nyiragongo的博客 4575

贪心+优先队列

优先队列&贪心 最近遇到很多题目的贪心都用优先队列来优化,现在简单的讲一讲一个比较难想到的优化 Moo University - Financial AidBessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and h

beckyUp的博客 583

《QT+PCL》点云的点选与框选

【代码】《QT+PCL》点云的点选与框选。

阁楼 3602

TMC2240 芯片数据手册解读|第十三篇 StallGuard4负载测量(StallGuard4 Load Measurement)

摘要: TMC2240的StallGuard4技术专为StealthChop2静音模式设计,通过SG4_RESULT实时测量电机负载,实现堵转检测、无传感器回零和CoolStep节能。其核心原理基于负载角检测,通过SG4_THRS阈值调节灵敏度,并支持四通道独立测量(SG4_IND_0~3)优化相位平衡。独特功能包括无抖动模式切换补偿(sg_angle_offset),解决StealthChop2与SpreadCycle切换时的电流突变问题。调优时需结合SG4_THRS设定与DIAG验证,确保堵转精准触发。

BackCatK Chen的博客 303

优先队列贪心

最近做了几个用优先队列进行贪心的题目,这里写下来,以免忘了。 1、CF 799 B http://codeforces.com/problemset/problem/799/B 每次选最便宜的衣服,没什么好说的,一发过 代码:#include<iostream> #include<cstring> #include<math.h> #include<cstdio> #include<alg

lyhuohuo的博客 418

8.19华为OD机试真题 新系统 - 基站低能耗时段统计 (Java/Py/C/C++/Js/Go)

8.19华为OD机试真题 新系统 - 基站低能耗时段统计 (Java/Py/C/C++/Js/Go)

算法大师! 1153

hdu 1387 Team Queue

Team Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2741    Accepted Submission(s): 944 Problem Description Queues and Priority

Timeclimber 589

爬虫不宕机!2026自愈式爬虫开发(Python+AI自动应对页面改版)

传统爬虫最大的痛点是"页面一改就宕机":前端布局调整、CSS选择器失效、数据结构变化,都会导致爬虫瘫痪,需要人工逐行修改代码。2026年,基于AI的自愈式爬虫成为行业标配:通过大模型自动识别页面结构变化、适配新的元素定位规则、修复数据提取逻辑,实现"页面改版不宕机,AI自动自愈"的企业级效果。本文从零讲解如何用Python+AI构建自愈式爬虫,聚焦页面改版自适应、故障自动修复、规则动态更新三大核心能力,附带可直接落地的生产级代码。问题场景解决方案LLM生成规则格式错误。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1215

微信小程序码 createWxaCodeUnlimit 生成总是报错 41030 的解决方案

41030错误本质上就是路径不合法。路径多写了一个斜杠路径带了参数小程序版本未发布或 app.json 配置不一致。如果确认页面存在,可以通过来跳过检查。微信小程序 getUnlimitedQRCode 官方文档路径前不能加 /,参数放 scene,发布版本要有这个页面,不行就关掉 check_path。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 475

51 nod 区间交 (优先队列)

1672 区间交 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题  收藏  关注 小A有一个含有n个非负整数的数列与m个区间,每个区间可以表示为li,ri。 它想选择其中k个区间, 使得这些区间的交的那些位置所对应的数的和最大。(是指k个区间共同的交,即每个区间都包含这一段,具体可以参照样例)

Timeclimber 547

彻底摆脱文献只能读开头的痛苦!这款文献检索神器真能帮你跨越文献付费限制(附实操演示)

大家是不是有过这样的经历,好不容易通过关键词搜到了和自己主题高度相关的文献,想要快速获取文献信息,推进研究进度,却又因为付费或者需订阅才能下载PDF,而被劝退。粘贴完成后,点击搜索,搜索结果页面会显示这篇文献的相关信息,有的文献有“下载PDF”,有的文献则只有“求助PDF”,不管是哪种情况,直接点击进入;我这里点击的是“下载PDF”,接着它会跳转页面。我用 Book 学术下载过不少付费文献,实测下来 80% 左右的文献,都能通过它的求助方式成功获取到,只有少部分文献等待的时间会稍微久一些或者没办法下载。

qq_64378896的博客 165

hdu 1873 (优先队列)

看病要排队 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10403    Accepted Submission(s): 4387 Problem Description 看病要排队这个是地球人都知道的常识。 不过经

Timeclimber 521

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

深度学习工具包 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 4022 Bombing(STL)

BombingTime Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 4834    Accepted Submission(s): 1813Problem DescriptionIt’s a cruel war which killed mill...

Timeclimber 514

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

hdu 4268 Alice and Bob(贪心)

Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4751    Accepted Submission(s): 1487 Problem Description Alice and Bob's

Timeclimber 493

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

2017 多校训练第二场 HDU 6047 Maximum Sequence(贪心+优先队列)

Maximum Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2404    Accepted Submission(s): 1131 Problem Description Steph is

Timeclimber 488

hdu 1242 disney (map模拟)

disney Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1039    Accepted Submission(s): 299 Problem Description   A new machine was intr

Timeclimber 488

hdu 1257 最少拦截系统(贪心)

最少拦截系统 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 44838    Accepted Submission(s): 17583 Problem Description 某国为了防御敌国的导弹袭击,发展出

Timeclimber 395

hdu 1237简单计算器 (栈的应用)

简单计算器 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23232    Accepted Submission(s): 8402 Problem Description 读入一个只包含 +, -, *, /

Timeclimber 382

hdu 1022 Train Problem(栈)

Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 38535    Accepted Submission(s): 14491 Problem Description As the new t

Timeclimber 381

Uva 10935 Throwing cards away I

Given is an ordered deck of n cards numbered 1 to n with card 1 at the top and card n at the bottom. The following operation is performed as long as there are at least two cards in the deck: Th

Timeclimber 363

hdu 4020 Ads Proposal(优先队列)

Ads ProposalTime Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 2427    Accepted Submission(s): 801Problem DescriptionThere are N customers set the...

Timeclimber 349

hdu 1238 Substrings(暴力枚举)

SubstringsTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11496    Accepted Submission(s): 5521Problem DescriptionYou are given a number of case...

Timeclimber 333

hdu 4288 Coder(STL)

CoderTime Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6452    Accepted Submission(s): 2400Problem Description  In mathematics and computer scie...

Timeclimber 327
上一篇: hdu 5517 Triple (二维树状数组)
下一篇: NEFU 1269(KMP)
Timeclimber
博客等级 码龄9年 25粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值