当前位置:网站首页>[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;
}
边栏推荐
- 2022 electrician (elementary) examination questions and electrician (elementary) registration examination
- MySQL——SQL注入问题
- Remember the experience of automatically jumping to spinach station when the home page was tampered with
- The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation
- JS Demo calcule combien de jours il reste de l'année
- Decompile and modify the non source exe or DLL with dnspy
- Intimacy communication -- [repair relationship] - use communication to heal injuries
- Sed、Awk
- MySQL——数据库备份
- Getting started with postman -- built-in dynamic parameters, custom parameters and assertions
猜你喜欢
Advanced technology management - how to examine candidates in the interview and increase the entry probability
Collections SQL communes
Compilation Principle -- syntax analysis
Asynchronous artifact: implementation principle and usage scenario of completable future
gslb(global server load balance)技術的一點理解
Monkey/ auto traverse test, integrate screen recording requirements
仿网易云音乐小程序
Persistence of Nacos
Imitation Netease cloud music applet
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
随机推荐
China's TPMS industry demand forecast and future development trend analysis report Ⓐ 2022 ~ 2028
QFileDialog
TiDB 之 TiCDC6.0 初体验
Are the top ten securities companies safe to open accounts and register? Is there any risk?
Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)
Covariance
MySQL——数据库备份
Common SQL sets
Under the double reduction policy, research travel may become a big winner
The 14th five year plan for the construction of Chinese Enterprise Universities and the feasibility study report on investment Ⓓ 2022 ~ 2028
Correlation
C程序设计的初步认识
(5) User login - services and processes - History Du touch date stat CP
JS notes (III)
MySQL——JDBC
China's coal industry investment strategic planning future production and marketing demand forecast report Ⓘ 2022 ~ 2028
Compréhension de la technologie gslb (Global Server load balance)
Introduction to kubernetes
2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
2022 safety officer-a certificate registration examination and summary of safety officer-a certificate examination