当前位置:网站首页>Hdu1422 revisits the world cup [DP]
Hdu1422 revisits the world cup [DP]
2022-07-27 14:12:00 【51CTO】
Topic link :
http://acm.hdu.edu.cn/showproblem.php?pid=1422
The main idea of the topic :
Here you are. N Cities , The tour route is 1~2~3~4~5~…~N~1. You can start from any city . Every city offers
The cost of living and the expenses required are different , ask : How many cities can you visit at most .
Ideas :
Because it can form a cycle , So connect it after the original data 1~N The data of . Then use dynamic programming to do . Status as : Become one
The remaining money in the city is not negative ( That is, the tour is not over yet ), If the money left in the previous city plus the money in the current city is greater than the current life
fee , that dp[i] = dp[i-1] + 1, Update the remaining money , If not enough travel , Just classify the rest of the money as 0, Starting from the current point
tourism , Calculate the biggest dp[i], What you get is the number of cities you can visit at most . Add an optimization here , When dp[i] == N( After visiting
N Cities ) When , Out of the loop .
AC Code :
边栏推荐
- Windows10 installing SQL Server 2019
- 基于C语言的LR1编译器设计
- 知识关联视角下金融证券知识图谱构建与相关股票发现
- 【论文精读】Grounded Language-Image Pre-training(GLIP)
- Wechat campus laundry applet graduation design finished product of applet completion work (3) background function
- Chapter 3 business function development (add clues and remarks, and automatically refresh the added content)
- Unity2d -- camera follow
- Redis cluster setup - use docker to quickly build a test redis cluster
- Zhishang technology IPO meeting: annual revenue of 600million, book value of accounts receivable of 270Million
- Experience sharing of system architecture designers preparing for the exam: a tough battle for nearly three months
猜你喜欢

uniapp的request数据请求简单封装步骤

基于在线问诊记录的抑郁症病患群组划分与特征分析

Electronic bidding procurement mall system: optimize traditional procurement business and speed up enterprise digital upgrading
![[training day3] delete [simulation]](/img/7b/217d4a9fa1426107eb7d6890dc9dc5.png)
[training day3] delete [simulation]

What are the benefits of taking NPDP
![[idea] set to extract serialVersionUID](/img/ef/7eee4639cd4306a2a7a53d73528bbd.png)
[idea] set to extract serialVersionUID

纯c手写线程池

Interview secrets are widely distributed, and the exclusive secrets of editing, testing and learning are leaked?!

Small program completion work wechat campus laundry small program graduation design finished product (2) small program function

Named entity recognition of Chinese electronic medical records based on Roberta WwM dynamic fusion model
随机推荐
Application layer World Wide Web WWW
Converter registration of easyexcel
uniapp的request数据请求简单封装步骤
Chapter 3 business function development (add clues and remarks, and automatically refresh the added content)
基于C语言实现线性表的建立、插入、删除、查找等基本操作
HDU4565 So Easy!【矩阵连乘】【推导】
基于企业知识图谱的企业关联关系挖掘
Shell编程规范与变量
记账软件如何查看收入支出
Utnet hybrid transformer for medical image segmentation
UTNet 用于医学图像分割的混合Transformer
How to return to the parent directory with commands
C#测量工具示意图
np.arange()和 range()的用法及区别
Travel notes from July 11 to August 1, 2022
A Keypoint-based Global Association Network for Lane Detection
CARLA 笔记(04)— Client 和 World (创建 Client、连接 World 、批处理对象、设置 Weather、设置 Lights、World snapshots)
认知篇----硬件工程师的成才之路之经典
「游戏引擎 浅入浅出」4.1 Unity Shader和OpenGL Shader
JWT login expiration - automatic refresh token scheme introduction