734C Anton and Making Potions

FoundationPose实战:从零部署到Demo运行全记录 本文详细记录了FoundationPose从零部署到Demo运行的全过程,包括Ubuntu环境配置、项目部署、依赖安装及常见问题解决方案。特别针对复现过程中的关键步骤如CUDA版本选择、Eigen3安装等提供了实用技巧,帮助开发者高效完成FoundationPose的部署与调试。 阅读详情

题目链接:

http://codeforces.com/problemset/problem/734/C

题解:

题目大意:
一个人升级需要n瓶药,这个人会两种魔法,第一种魔法可以缩减炼药的时间,另一种可以瞬间完成一些药。一瓶药在没有释放任何魔法的情况下,炼制的时间为x,并且,这个人所拥有的法力值为s,但是一个人最多每种魔法使用一次(注意不是每个),问你炼制这些药的最小的时间是多少。
这道题的数据的范围比较大,常规的暴力一定会超时,因此,这里很容易想到需要使用二分的方法。主要的问题是怎么来二分。我们可以这么想,我们对于第一种魔法的选择进行枚举,在魔力满足的条件下在尽可能的选择第二种。最后,将再对只取第二种的的贪心情况进行比较就可以了。
这里的二分,我是直接用stl里面的upper_bound,(一开始队友把lower_bound和upper_bound给记错了,下次还是要自己记住。)
upper_bound返回的是大于等于,lower_bound返回的是大于。

代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define met(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int maxn = 2e5+10;
typedef long long ll;
ll num1[maxn],num2[maxn],num3[maxn],num4[maxn];

int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    int x,s;
    scanf("%d%d",&x,&s);
    for(int i=1;i<=m;i++)
        scanf("%I64d",&num1[i]);
    for(int i=1;i<=m;i++)
        scanf("%I64d",&num2[i]);
    for(int i=1;i<=k;i++)
        scanf("%I64d",&num3[i]);
    for(int i=1;i<=k;i++)
        scanf("%I64d",&num4[i]);
    ll ans=(n-num3[upper_bound(num4+1,num4+1+k,s)-num4-1])*x;
    for(int i=1;i<=m;i++)
    {
        if(num2[i]<=s)
            ans=min(ans,(n-num3[upper_bound(num4+1,num4+1+k,s-num2[i])-num4-1])*num1[i]);
    }
    printf("%I64d\n",ans);
}

友情提醒:c++11不支持%lld的输入。

使用MATLAB进行灰色预测 GM(1,1) 阅读详情

相关推荐

深入解析经典蓝牙连接:从HCI命令到LMP协议的完整流程

本文深入解析经典蓝牙连接的完整流程,从设备发现、寻呼建立物理链路,到安全配对与加密的每一步。通过对照HCI LOG与AIR LOG,详细拆解了HCI命令与LMP协议报文的对应关系,帮助开发者精准定位连接问题,掌握蓝牙调试的核心方法。

weixin_29260291的博客 470

Codeforces-734C-Anton and Making Potions(枚举+二分)

C. Anton and Making Potions time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Anton is playing a very interesting computer game, but now he

Prim 618

基于STM32F103C8T6的红外循迹避障小车

编程思路:控制核心板IO口的电平(即电机驱动模块的AIN1,AIN2,BIN1,BIN2)从而控制AO1、AO2、BO1、BO2的电平高低,进而控制电机使其正转、反转、不转。由于单纯地拉高拉低电平只能让电机在转与不转的状态切换,故决定利用TIM4的两个通道分别产生两路PWM信号来控制电机速度,四个电机两个一组,同一侧的两个连接在同一个PWM上。(#include "dianji.h"文件中同时写了对循迹模块引脚的初始化)

weixin_48743503的博客 1万+

Codeforce#379C. Anton and Making Potions(二分or贪心)

Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare npotions. Anton has a special kettle, that can prepare one p

Rain 798

YOLOv5轻量化实战:从Ghost模块到工业级部署的完整指南

本文详细介绍了YOLOv5轻量化实战,重点解析了Ghost模块在工业检测中的应用及其优化策略。通过Ghost卷积技术,模型参数量和GFLOPs显著降低,同时保持高精度,适用于实时性要求严格的工业场景。文章还提供了从模型优化到TensorRT加速的完整部署指南,助力开发者实现高效工业级应用。

weixin_28223453的博客 493

C#利用S7netplus实现西门子S7_200_SMART PLC高效点位监控与操作

本文详细介绍了如何使用C#结合S7netplus开源库高效监控与操作西门子S7-200 SMART PLC的点位。内容涵盖从开发环境搭建、建立通信连接,到核心的点位读写、批量数据处理及字节与位数组转换等关键技术,并提供了构建稳定监控程序的架构与避坑指南,帮助开发者快速实现上位机与PLC的稳定数据交互。

rum55的博客 317

【Codeforces 734 C Anton and Making Potions 】+ 思维

C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard outputAnton is playing a very interesting computer game, but n

楚江枫 761

SAP-ABAP:SAP数据库视图(Database View)详解-创建

数据库视图是SAP中实现多表关联查询的基础工具,适合简单的跨表查询和权限控制场景。但其功能有限,对于复杂逻辑或高性能需求,建议结合CDS视图或ABAP程序开发。通过合理设计,数据库视图可显著提升开发效率和系统可维护性。它存储在数据库中,但本身不存储数据,仅通过查询动态生成结果。是一种基于物理数据库表的虚拟表,通过关联多个表(使用。

baidu_35680696的博客 1376

Codeforces Round #379 (Div. 2)C. Anton and Making Potions(二分)

C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interes

fouzhe的博客 605

Java使用POI生成柱状图导出到word文档(柱状图)

本篇文章主要介绍,如何使用Apache POI组件生成柱状图导出到word文档中,具体步骤看下文。 一、实现效果 Java使用POI技术生成柱状图导出到word文档中,最终生成的柱状图如下所示: 二、环境准备 编程语言:Java 第三方依赖:Apache POI Apache POI依赖代码如下所示: <dependencies> <dependency> <groupId>org.apache.poi</groupId.

✅ Java 开发工程师 7396

【学习系列】SAP RAP 29:如何创建Application Jobs(下)

本文介绍了在SAP系统中通过API创建和使用Application Jobs的方法。主要内容包括:1) 创建RAP应用并通过Action调用API创建Jobs;2) 使用事件驱动方式异步更新Job状态;3) 通过URL跳转到标准日志页面;4) 使用Custom Entity获取Job日志;5) 演示遗留接口IF_APJ_DT_EXEC_OBJECT和IF_APJ_RT_EXEC_OBJECT的使用。文章提供了详细的代码示例,展示了如何通过CL_APJ_RT_API=>SCHEDULE_JOB调度作业,

DeveloperMrMeng的博客 394

CodeForces - 734C Anton and Making Potions 二分+贪心 思维题

题意:有n件物品要完成,完成每件物品的时间是x。有两种buff。第一种有m个,每个消耗bi法力值,可以使制作时间变为ai。第二种有k个,每个消耗法力值di,可以瞬间完成ci个物品。现在你有s点法力值,每种buff最多只能使用一个。求最少的完成时间。 题解:枚举第一种buff,然后二分搜索s-bi。因为第二种buff的法力值和完成件数是升序的,可以直接进行二分。

ACZone 391

修改legged_gym地形后仍然是平地,如何解决?

🏆 本文收录于《全栈Bug调优(实战版)》专栏,致力于分享我在项目实战过程中遇到的各类Bug及其原因,并提供切实有效的解决方案。无论你是初学者还是经验丰富的开发者,本文将为你指引出一条更高效的Bug修复之路,助你早日登顶,迈向财富自由的梦想🚀!同时,欢迎大家关注、收藏、订阅本专栏,更多精彩内容正在持续更新中。让我们一起进步,Up!Up!Up!    备注: 部分问题/难题源自互联网,经过精心筛选和整理,结合数位十多年大厂实战经验资深大佬经验总结所得,数条可行方案供所需之人参考。

**My Coding Family** 1570

CodeForces - 734C Anton and Making Potions(二分)

CodeForces - 734C   Anton and Making Potions题目:有n个药剂需要制作,制作每个药剂需要time秒钟,并且最初有w的能量;魔法师现在有两种催化剂,第一种可以消耗fc[i]的能量,使得所有药剂的所需时间变为fw[i];第二种消耗能量sc[i],使得sw[i]个数的药剂瞬间制作好;但两种催化剂每种只能最多选择一种,问最后最少需要多少时间;思路:注意到第二种的催...

GYH0730的博客 378

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

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

CodeForces 734C - Anton and Making Potions(枚举)

C. Anton and Making Potions time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Anton is playing a very interesting computer game, but now he

Snakeflute的博客 531

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

【13.77%】【codeforces 734C】Anton and Making Potions

time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Anton is playing a very interesting computer game, but now he is stuck at on...

AWCXV 137

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

CodeForces - 734C Anton and Making Potions (二分)

题目链接;http://codeforces.com/problemset/problem/734/C点击打开链接 C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input

xuejye的博客 442

CodeForces 734C Anton and Making Potions 【二分】【贪心】

题目:点击打开链接 题意:要制作n个药,初始制作一个药的时间为x,魔力值为s,有两类咒语可以加速,一类有m种咒语,每种咒语使制作一个药的时间变成a[i],花费b[i]的魔力,二类有k种咒语,每种咒语瞬间产生c[i]个药,花费d[i]的魔力,c[i]和d[i]都是不递减的,求最短时间内产生n个药的时间。 分析:总花费的时间ans=(n-c[j])*a[i],b[i]+d[j] #pragma

代码中转站 402

Codeforces 734C. Anton and Making Potions

C. Anton and Making Potions time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Anton is playing a very interesting computer game, but now he

Assassin 453

Codeforce 734C Anton and Making Potions 枚举+二分

点击打开链接 #include #include #include #include #include #include using namespace std; typedef long long ll; const int N=1e5+20; const ll inf=1e18; ll a[N],b[N],c[N],d[N]; int main() { ll n,x,s; l

Masamiiiiii 560

CodeForce-734C Anton and Making Potions(贪心+二分)

CodeForce-734C Anton and Making Potions C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output stand...

169

CodeForces 734C - Anton and Making Potions

题意:你需要生产nn个药剂,现在你有两种操作,一种是将生产一瓶药剂的时间xx变成aia_i,这个操作需要花费bib_i。第二个操作是立刻生产cic_i瓶药剂,这种操作花费did_i。第一种操作总共有kk种,第二种操作总共有mm种。问在花费不超过ss的情况下,生产nn瓶药水所需要花费的最少时间。题目保证dd的输入是递增的。且每种操作只能选择一种。思路:比较显然的是如果不考虑第一种操作,只考虑第二种操作

宝树啊宝树 609

CodeForces 734C Anton and Making Potions 二分或线段树

题意: 你要制作n个药,初始制作一个药的时间为x,魔力值为s,有两类咒语可以加速,一类有m种咒语,每种咒语使制作一个药的时间变成a[i],花费b[i]的魔力,二类有k种咒语,每种咒语瞬间产生c[i]个药,花费d[i]的魔力,c[i]和d[i]都是不递减的,求最短时间内产生n个药的时间。 思路: 题目中明确说明了,对于第二类咒语,魔力值花的越多,瞬间产生的药也越多。所以我们可以枚举第一种咒语,

DT2131 580

Codeforces 734C Anton and Making Potions【二分】

C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interesting compu

mengxiang000000 611

Codeforces 734C Anton and Making Potions(二分)

C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interes

Chunzhen的博客 1255

Codeforces 734C. Anton and Making Potions(二分)

Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to preparenpotions. Anton has a special kettle, that can prepare ...

awow80285的博客 140
上一篇: 数据结构——线段树
下一篇: 782B The Meeting Place Cannot Be Changed
kicksilver7
博客等级 码龄11年 0粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值