Contest Balloons

Contest Balloons

题目链接:http://codeforces.com/problemset/problem/725/D

贪心+枚举

每次在排名在自己前面的选出w-t值最小的送气球,更新rank即可。

(一直觉得cin比scanf不会慢太多,结果我跑出来是2000ms,队友300ms...)

代码如下:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<queue>
 5 #define Min(x,y) (x<y?x:y)
 6 #define N 300005
 7 using namespace std;
 8 typedef long long LL;
 9 LL n,k,t,w,rk,ans,index;
10 struct nod{
11     LL t,w,diff;
12     nod(LL tt=0,LL ww=0){
13         t=tt,w=ww;
14         diff=w-t;
15     }
16     bool operator < (const nod &b)const{
17         return diff>b.diff;
18     }
19 }a[N];
20 bool cmp(nod a,nod b){
21     return a.t>b.t;
22 }
23 priority_queue<nod>pq;
24 int main(void){
25     scanf("%I64d",&n);
26     scanf("%I64d%I64d",&t,&w);
27     for(LL i=1;i<n;++i){
28         LL t,w;
29         scanf("%I64d%I64d",&t,&w);
30         if(t<=w)a[k++]=nod(t,w);
31     }
32     sort(a,a+k,cmp);
33     for(;index<k;++index){
34         if(a[index].t<=t)break;
35         pq.push(a[index]);
36     }
37     rk=ans=index+1;
38     while(!pq.empty()){
39         nod temp=pq.top();
40         pq.pop();
41         t-=temp.diff+1;
42         if(t<0)break;
43         LL i=0;
44         for(;i+index<k;++i){
45             if(a[i+index].t<=t)break;
46             pq.push(a[i+index]);
47         }
48         rk+=i-1;
49         index+=i;
50         ans=Min(ans,rk);
51     }
52     printf("%I64d\n",ans);
53 }

 

转载于:https://www.cnblogs.com/barrier/p/5990077.html

【人工智能】Gemini怎么使用智能体的能力? Gemini Gems: 定制你的AI智能体 Gems 是 Gemini 的定制版本。你可以通过设定特定的指令(Instructions),让它变成你需要的专家。一旦创建,它会记住这些设定,你不需要在每次对话时重复输入背景信息。目前创建和使用自定义 Gems 通常需要订阅(Google One AI Premium 计划)。对于大多数用户来说,Gemini Advanced 中的 Gems是使用智能体能力的最直接方式。它能让你把重复性的提示词封装成一个好用的工具。 阅读详情

相关推荐

RTKLIB模糊度固定实战:三种模式对比与部分模糊度固定代码解析

本文深入解析RTKLIB中模糊度固定的三种核心模式(continuous、instantaneous、fix and hold),对比其性能与适用场景,并详细拆解了部分模糊度固定技术的源码实现。通过实战案例与代码级解析,为GNSS高精度定位开发者提供了在不同数据特性下提升固定成功率的优化思路与配置建议。

efc1234567的博客 477

D. Contest Balloons(贪心详解)

想了几分钟就出思路了 当然也不是说这题水,但我就是莫名的思路清晰hh? 开始肯定想到二分给的气球数,但是答案没有单调性 那么这么大的范围,就只有贪心了!! 名次想前进,就必须给气球给前面的使他们漂浮起来名次想前进,就必须给气球给前面的使他们漂浮起来名次想前进,就必须给气球给前面的使他们漂浮起来 我们维护一个按照(w−t)小优先级大的优先队列q我们维护一个按照(w-t)小优先级大的优先队列q我们维护一个按照(w−t)小优先级大的优先队列q q中的人气球都比我多q中的人气球都比我多q中的人气球都比我多 假如我

jziwjxjd的博客 504

用Cadence IC618仿真双平衡吉尔伯特混频器:从原理图到后仿的完整避坑指南

本文详细介绍了在Cadence IC618环境中设计双平衡吉尔伯特混频器的全流程,包括原理图设计、仿真优化和版图实现。通过实战案例分享,重点解析了设计中的关键技巧和常见问题解决方案,帮助工程师高效完成高性能混频器设计,特别适合射频前端开发人员参考。

weixin_42656416的博客 165

前端工程化实践:基于Savor的配置即代码与约定优于配置

在现代前端开发中,工程化配置是提升开发效率和代码质量的关键环节。其核心原理在于通过工具链自动化处理构建、代码检查和格式化等重复性工作,从而让开发者更专注于业务逻辑实现。这一技术价值体现在减少配置成本、统一团队规范、保障项目长期可维护性。常见的应用场景包括新项目快速启动、团队协作规范统一以及技术债务控制。本文以Savor项目为例,深入解析其如何实践“配置即代码”和“约定优于配置”理念,通过预置Vite、TypeScript、ESLint等最佳实践工具链,为开发者提供开箱即用的工程化解决方案,特别适合独立开发者

weixin_30512043的博客 486

深入解析高通8155平台音频数据流:从HAL到DSP的完整链路

本文深入解析了高通8155平台音频数据从安卓HAL层到DSP的完整传输链路。以播放场景为例,详细阐述了音频数据如何通过ASoC DPCM框架进行路由、打包,并经由APR协议与DSP交互,最终驱动硬件发声的核心流程,为车载音频系统开发与调试提供了清晰的框架。

rust6ferris的博客 1183

保姆级教程:在DJI无人机遥控器上部署YOLOv8模型(基于MSDK 5.0与NCNN)

本文详细介绍了在DJI无人机遥控器上部署YOLOv8模型的保姆级教程,基于MSDK 5.0与NCNN框架实现边缘计算。通过视频流处理、模型转换与优化、多线程同步等关键技术,实现在遥控器端完成目标检测任务,适用于野外作业、应急响应等场景。

weixin_42561476的博客 257

CodeForces ~ 998A ~ Balloons (水)

题意 n个数字分给两个人,使得A得到的数字和大与B得到的数字和,输出A的得到的数字的下标(任意解且顺序随意),如果无解输出-1。 思路 直接把最小的给B,其他的全给A。 #include &lt;bits/stdc++.h&gt; using namespace std; const int MAXN = 505; const int INF = 0x3f3f3f3f; int n, ...

张松超的博客 495

Navicat16/17数据库密码安全解析与实战解密指南

本文详细解析了Navicat 16/17版本中数据库密码的加密机制,并提供了实用的密码找回指南。通过导出连接文件获取加密密文,利用基于AES-128-CBC算法的本地HTML工具,可安全、离线地解密遗忘的密码。文章强调该方法仅适用于合法恢复自有密码,并给出了操作步骤与安全建议。

weixin_28835583的博客 479

HDU 6407 Pop the Balloons

题意:Ex打气球,气球爆了会吹飞同行同列的气球,求引爆K次气球使所有气球消失的方案数。 行列:N&lt;=12 , M&lt;=20 。K &lt;=20 各种分析,然后发现你只能打K行,每行每列只能打一个,那么就二进制枚举呗(N&lt;=12) 然后一个状压DP就行了, 从左到右枚举列 , 如果这列除了这K行外还有气球存在,那么这列一定要引爆一个,否则可以不引爆,但是最多只能引爆一个。...

Freopen的博客 539

29. 如何通过 ABAP 代码给 SAP OData 元数据增添注解

我们先看下效果,在 MPC_EXT 类的 DEFINE 方法里编写 ABAP 代码之后,用 Postman 使用 url 访问 OData metadata,在返回的数据里,能看到我们用 ABAP 代码添加的自定义注解。你好,请问可以不可以在odata里面通过什么设置,从而自动给metadata.xml中加上注解,实现value help的功能,还是说每次需要在metadata.xml中修改?的词汇引用,然后为命名空间 com.sap.vocabularies.UI.v1 声明了一个别名。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1669

YOLOv11 改进 - 主干网络| 清华大学CloFormer AttnConv :利用共享权重和上下文感知权重增强局部感知,注意力机制与卷积的完美融合

本文介绍了轻量级视觉变换器CloFormer及其核心模块AttnConv在YOLOv11中的结合应用。为解决视觉变换器缩小到移动设备友好尺寸时性能下降的问题,提出CloFormer,其引入AttnConv操作符。AttnConv融合共享权重和上下文感知权重,先通过深度卷积提取局部表示,再用上下文感知权重增强特征,还结合传统注意力减少FLOPs,使模型感知高频和低频信息。我们将AttnConv集成进YOLOv11,实验表明,CloFormer在多个视觉任务中表现优越,改进后的YOLOv11也取得了良好实验结果

魔改工程师的博客 991

Canada Cup 2016 D. Contest Balloons详解(贪心+优先队列)

D. Contest Balloons time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output One tradition of ACM-ICPC contests is t

K键盘里的青春K 852

31、工程中不确定性量化与优化的全面解析

本文全面解析了工程中不确定性量化与优化的关键方法。针对数据充足与不足两种情况,分别介绍了概率理论和非概率方法在不确定性建模中的应用;系统阐述了采样方法、FORM/SORM、泰勒级数近似等不确定性传播技术;深入比较了RBDO与RDO两种主流优化框架的原理、步骤及适用场景,并通过两杆桁架案例展示了具体实现过程。文章旨在为工程师提供一套完整的从不确定性分析到优化设计的方法论,提升工程系统的可靠性与稳健性。

php55的博客 125

CF Contest Balloons

传送门题意给定几个队伍,获得的气球数和最大的可承受气球数。当气球数大于最大可承受值是,不参与排名。自己的队伍可以给任何队伍不超过自己气球数的气球,使他们不参与排名。 求自己最好的名次,分析很显然,是贪心的想法 但是实现上,有点犯难了。贪心的策略是这样的,先把比自己队伍气球多并且最容易使其失败的队伍开始。一直在想,可不可以直接一次排序达成。这样就必须考虑气球数和差值。用一个函数来拟合。。。。发现想骗

ACMer的博客 494

深度学习工具包 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")

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

codeforces 725D Contest Balloons

题句题意很容易理解:Limak可以把自己获得的气球送给别人,使别人的气球大于体重。从而让别人漂浮的天花板上,不能参与排名,从而使Limak自己的排名上升。这个题目是一个典型的贪心,当Limak把自己的气球给别人的时候,他自己的手中的气球就会减少,那么他自己的排名也是有可能降低的。那么,我们就需要思考,Limak应该把气球给什么样的人,他自己的排名才有可能上升。其实,很简单,他肯定是把气球给当前排名

ZT在努力 499

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Codeforces 725D[Contest Balloons]【贪心】

DescriptionOne tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn’t matter and teams are sorted only by the number of balloo

Sdywolf的博客 432

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

CF725D Contest Balloons

题目链接https://www.luogu.org/problemnew/show/CF725D 考虑这样一个贪心,当我们在某时已经是第一名时就不用再送人上天了,否则每次就送最容易上天的队伍上天,然后更新名次,更新答案,将上天的队伍踢出,可以用优先队列实现 当前的名次等于得分比我们大的总队伍个数+1   #include&lt;iostream&gt; #include&lt;cstdi...

amdkk的博客 281

codeforce 725D Contest Balloons

贪心

forezxl的博客 362

Codeforces 725D Contest Balloons

首先将每个队伍按照气球量从大到小排序,将大于XXX的队伍压入队列,在队列中按照 体重-气球量+1 从小到大排序。 当XXX的气球减少时,就需要把之前没进入队列但此时气球量大于XXX的队伍压入队列,不断更新最小ans。#include <cstdio> #include <cstdlib> #include <algorithm> #include <queue> #define ll long lo

社会福利公社 311

Canada Cup 2016 D. Contest Balloons

One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn’t matter and teams are sorted only by the number of balloons they have. It means that one’s place is equal to the number of

m0_69367351的博客 1102

Codeforces 725D. Contest Balloons

这样我们得到了每一步的最优做法:尝试放飞名次比自己靠前的,同时我们想让自己气球数下降的尽可能少以保持名次,则优先放飞所需放飞气球数少的队(使用优先队列使其在堆中上浮)。每次放飞后我们立刻查询自己当前的名次,更新最好名次,单次查询O(n)则必然超时,不妨排序后使用二分查找单次查询O(logn),更新最好名次后再更新优先队列,单次更新O(logn),最多更新n次,总时间复杂度O(nlogn),可以AC。Limak 是第一队的成员。如果一队的气球数大于该队的重量,该队就会开始和他们的工作台一起漂浮在空中。

weixin_44208684的博客 490

【37.74%】【codeforces 725D】Contest Balloons

time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output One tradition of ACM-ICPC contests is that a team gets a balloon for every s...

AWCXV 147

【题解】codeforces725D Contest Balloons

One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn’t matter and teams are sorted only by the number of balloons they ha...

ModestCoder_的博客 692

[堆 贪心] Canada Cup 2016 D. Contest Balloons

不想多说 #include #include #include #include using namespace std; typedef long long ll; typedef pair abcd; inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; if (p1==p2) { p2=(p1=buf)+fr

雯舞 373

CodeForces - 725D Contest Balloons 贪心

D. Contest Balloons time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output One tradi...

weixin_34144848的博客 181
上一篇: Ubuntu命令行shell显示中文
下一篇: SVN命令之更新到指定版本
weixin_34129696
博客等级 码龄11年 4479粉丝 1267原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值