当前位置:网站首页>[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;
}
边栏推荐
- How to store null value on the disk of yyds dry inventory?
- Decompile and modify the non source exe or DLL with dnspy
- Mysql - - Index
- MySQL -- standardize database design
- 4. Data splitting of Flink real-time project
- Report on the current situation and development trend of ethoxylated sodium alkyl sulfate industry in the world and China Ⓞ 2022 ~ 2027
- C程序设计的初步认识
- Yyds dry inventory Chapter 4 of getting started with MySQL: data types that can be stored in the data table
- Imitation Netease cloud music applet
- Minio deployment
猜你喜欢
MySQL - index
使用dnSpy对无源码EXE或DLL进行反编译并且修改
No more! Technical team members resign collectively
Compréhension de la technologie gslb (Global Server load balance)
The post-90s resigned and started a business, saying they would kill cloud database
Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
(5) User login - services and processes - History Du touch date stat CP
How PHP drives mongodb
使用dnSpy對無源碼EXE或DLL進行反編譯並且修改
gslb(global server load balance)技術的一點理解
随机推荐
Getting started with DOM
China's coal industry investment strategic planning future production and marketing demand forecast report Ⓘ 2022 ~ 2028
使用dnSpy對無源碼EXE或DLL進行反編譯並且修改
Selenium has three waiting methods (forced waiting, implicit waiting, and display waiting)
DR-NAS26-Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-5GHz-high-power-Mini-PCIe-Wi-Fi-Module
90 后,辞职创业,说要卷死云数据库
Introduction to kubernetes
Memory analyzer (MAT)
Yiwen teaches you how to choose your own NFT trading market
MySQL - index
Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
油猴插件
2022 high altitude installation, maintenance and removal of examination question bank and high altitude installation, maintenance and removal of examination papers
JS demo calculate how many days are left in this year
Implementation principle of inheritance, encapsulation and polymorphism
2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
Is it OK for fresh students to change careers to do software testing? The senior answered with his own experience
How PHP adds two numbers
Day 9 HomeWrok-ClassHierarchyAnalysis
请教大家一个问题,用人用过flink sql的异步io关联MySQL中的维表吗?我按照官网设置了各种