当前位置:网站首页>[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
2022-07-03 21:57:00 【muse_ age】

The question : Find the maximum value of the sum of increasing subsequences
dp[i]: With nums[i] The maximum value of the sum of increasing subsequences at the end
initialization : dp[0]=nums[0]
State transition equation : dp[i]=max{dp[j]}+num[i] if(nums[j]<nums[i]) 0<=j<i
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int nums[100];
for(int i=0;i<n;i++){
cin>>nums[i];
}
int dp[100];
for(int i=0;i<n;i++)
dp[i]=nums[i];
int res=0;
for(int i=1;i<n;i++){
for(int j=0;j<i;j++){
if(nums[j]<nums[i])
dp[i]=max(dp[i],dp[j]+nums[i]);
res=max(res,dp[i]);
}
}
cout<<res;
} 边栏推荐
- DR-NAS26-Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-5GHz-high-power-Mini-PCIe-Wi-Fi-Module
- The 14th five year plan and investment feasibility study report of China's industry university research cooperation Ⓧ 2022 ~ 2028
- Pengcheng cup Web_ WP
- Introduction to kubernetes
- 常用sql集合
- UC Berkeley proposes a multitask framework slip
- Dynamic research and future planning analysis report of China's urban water supply industry Ⓝ 2022 ~ 2028
- Day 9 HomeWrok-ClassHierarchyAnalysis
- What is the content of the securities practice examination?
- 2022 free examination questions for safety management personnel of hazardous chemical business units and reexamination examination for safety management personnel of hazardous chemical business units
猜你喜欢

UC Berkeley proposes a multitask framework slip

MySQL——索引

Notes on MySQL related knowledge points (startup, index)

MySQL - database backup

Day 9 HomeWrok-ClassHierarchyAnalysis

Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)

使用dnSpy对无源码EXE或DLL进行反编译并且修改

常用sql集合

技术管理进阶——如何在面试中考察候选人并增大入职概率

Station B, dark horse programmer, employee management system, access conflict related (there is an unhandled exception at 0x00007ff633a4c54d (in employee management system.Exe): 0xc0000005: read locat
随机推荐
[SRS] build a specified version of SRS
China's TPMS industry demand forecast and future development trend analysis report Ⓐ 2022 ~ 2028
How to store null value on the disk of yyds dry inventory?
The post-90s resigned and started a business, saying they would kill cloud database
2022 safety officer-a certificate registration examination and summary of safety officer-a certificate examination
Compilation Principle -- syntax analysis
Imitation Netease cloud music applet
Yiwen teaches you how to choose your own NFT trading market
What should the future of the Internet be like when Silicon Valley employees flee the big factory and rush to Web3| Footprint Analytics
China's Call Center Industry 14th five year plan direction and operation analysis report Ⓔ 2022 ~ 2028
On my first day at work, this API timeout optimization put me down!
JS Demo calcule combien de jours il reste de l'année
Dynamic research and future planning analysis report of China's urban water supply industry Ⓝ 2022 ~ 2028
An expression that regularly matches one of two strings
2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers
MySQL——idea连接MySQL
抓包整理外篇——————autoResponder、composer 、statistics [ 三]
Miscellaneous things that don't miss the right business
MySQL——JDBC
Control loop of program (while loop)