当前位置:网站首页>HDU1422 重温世界杯【DP】
HDU1422 重温世界杯【DP】
2022-07-27 12:59:00 【51CTO】
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1422
题目大意:
给你N个城市,参观路线为1~2~3~4~5~…~N~1。可以从任何一座城市开始参观。每座城市提供的
生活费和需要的花费都不同,问:最多能参观多少个城市。
思路:
因为能形成循环,所以在原有数据的后边再接上1~N的数据。然后用动态规划来做。状态为:当上一
个城市剩下的钱不为负(即还未结束旅游),如果上一个城市剩下的钱加上当前城市的钱大于当前的生活
费,那么dp[i] = dp[i-1] + 1,更新剩下的钱,如果不够旅游了,就将剩下的钱归为0,从当前点开始
旅游,计算最大的dp[i],得到的就是最多能参观的城市数。这里加一个优化,当dp[i] == N(即参观完
N个城市)的时候,跳出循环。
AC代码:
边栏推荐
- Cognition -- classic of the road to success of hardware engineers
- NoSQL —— NoSQL 三大理论基石 —— CAP —— BASE—— 最终一致性
- 小程序毕设作品之微信校园洗衣小程序毕业设计成品(8)毕业设计论文模板
- Design of LR1 compiler based on C language
- Small program completion work wechat campus laundry small program graduation design finished product (2) small program function
- Download address of each version of libtorch
- [training day4] anticipating [expected DP]
- 利用C语言实现URL解析的基本方法之优秀
- CARLA 笔记(04)— Client 和 World (创建 Client、连接 World 、批处理对象、设置 Weather、设置 Lights、World snapshots)
- Golang excellent open source project summary
猜你喜欢

平板模切机

小程序毕设作品之微信校园洗衣小程序毕业设计成品(4)开题报告
![[luogu_p4556] [Vani has an appointment] tail in rainy days / [template] segment tree merging](/img/e3/c2b3d45c6a0d1f7ff0b8b7bccf2106.png)
[luogu_p4556] [Vani has an appointment] tail in rainy days / [template] segment tree merging

UTNet 用于医学图像分割的混合Transformer

Wechat campus laundry applet graduation design finished product of applet completion work (3) background function

13. User web layer services (I)

Thinkphp+ pagoda operation environment realizes scheduled tasks

One of yolox improvements: add CBAM, Se, ECA attention mechanism

Pure C handwriting thread pool

Cultural tourism and data collection | travel to Yunnan in an artistic way
随机推荐
阿里最新股权曝光:软银持股23.9% 蔡崇信持股1.4%
Accuracy improvement method: efficient visual transformer framework of adaptive tokens (open source)
A Keypoint-based Global Association Network for Lane Detection
小程序毕设作品之微信校园洗衣小程序毕业设计成品(7)中期检查报告
Interview eight part essay · TCP protocol
Cognition -- classic of the road to success of hardware engineers
Software testing system architecture designer concise tutorial | software testing
[training day3] section [greed] [two points]
基于预训练模型的多标签专利分类研究
The most complete collection of strategies! Super AI painting tool midjourney open beta! Come and build your fantasy metauniverse
Design of LR1 compiler based on C language
idea Gradle7.0+ :Could not find method compile()
Thinkphp+ pagoda operation environment realizes scheduled tasks
[training day4] card game [greed]
认知篇----硬件工程师的成才之路之经典
[training day4] anticipating [expected DP]
See if you are on the shortlist of each division
Lighting 5g in the lighthouse factory, Ningde era is the first to explore the way made in China
基于在线问诊记录的抑郁症病患群组划分与特征分析
基于C语言的LR1编译器设计