题解:AtCoder AT_awc0006_b Efficient Quests
本文分享的必刷题目是从蓝桥云课、洛谷、AcWing等知名刷题平台精心挑选而来并结合各平台提供的算法标签和难度等级进行了系统分类。题目涵盖了从基础到进阶的多种算法和数据结构旨在为不同阶段的编程学习者提供一条清晰、平稳的学习提升路径。欢迎大家订阅我的专栏算法题解C与Python实现附上汇总贴算法竞赛备考冲刺必刷题C | 汇总【题目来源】AtCoderB - Efficient Quests【题目描述】Takahashi is playing an RPG game. The game hasN NNquests, and thei ii-th quest( 1 ≤ i ≤ N ) (1 \leq i \leq N)(1≤i≤N)has a stamina cost ofD i D_iDiand an experience reward ofR i R_iRi. For each quest, he can choose either not to clear it or to clear it exactly once.高桥正在玩一款 RPG 游戏。游戏中有N NN个任务第i ii个任务1 ≤ i ≤ N 1 ≤ i ≤ N1≤i≤N的体力消耗为D i D_iDi经验值奖励为R i R_iRi。对于每个任务他可以选择不清除或者恰好清除一次。Takahashi has a playstyle of “only clearing efficient quests.” For Takahashi, anefficient questis one whose experience reward is at leastK KKtimes its stamina cost, that is, a quest satisfyingR i ≥ K × D i R_i \geq K \times D_iRi≥K×Di. Here,K KKis the efficiency threshold multiplier set by Takahashi.高桥的玩法是只清除高效任务。对高桥而言一个高效任务是指其经验值奖励至少为体力消耗的K KK倍即满足R i ≥ K × D i R_i ≥ K × D_iRi≥K×Di的任务。此处K KK是高桥设定的效率阈值倍数。Following this playstyle, Takahashi clears all efficient quests and does not clear any other quests.遵循这种玩法高桥会清除所有高效任务并且不清除任何其他任务。Determine whether the total experience gained from the quests Takahashi clears following this playstyle is at least the target experienceT TT.判断高桥遵循这种玩法所清除任务获得的总经验值是否至少达到目标经验值T TT。【输入】N NNK KKT TTD 1 D_1D1R 1 R_1R1D 2 D_2D2R 2 R_2R2⋮ \vdots⋮D N D_NDNR N R_NRNThe first line contains the number of questsN NN, the efficiency threshold multiplierK KK, and the target experienceT TT, separated by spaces.From the 2nd line to the( N 1 ) (N 1)(N1)-th line, the information for each quest is given.The( 1 i ) (1 i)(1i)-th line contains the stamina costD i D_iDiand the experience rewardR i R_iRiof thei ii-th quest, separated by spaces.【输出】If the total experience gained when Takahashi clears all efficient quests is at least the target experienceT TT, printYes; otherwise, printNo.【输入样例】3 2 100 10 30 5 15 8 20【输出样例】No【解题思路】【算法标签】#模拟#【代码详解】#includebits/stdc.husingnamespacestd;#defineintlonglongintn,k,t,ans;// n: 数据组数k: 阈值系数t: 目标值ans: 满足条件的奖励总和signedmain(){cinnkt;// 读入数据组数、阈值系数和目标值for(inti1;in;i){intd,r;// d: 距离/次数r: 奖励cindr;// 读入距离/次数和奖励// 如果奖励大于等于k倍的距离/次数if(rk*d){ansr;// 累加奖励}}// 判断累计奖励是否达到目标值if(anst){coutYesendl;}else{coutNoendl;}return0;}【运行结果】3 2 100 10 30 5 15 8 20 No
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2566813.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!