当前位置:网站首页>[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;
} 边栏推荐
- Dahua series books
- gslb(global server load balance)技术的一点理解
- Global and Chinese market of recycled yarn 2022-2028: Research Report on technology, participants, trends, market size and share
- QFileDialog
- WiFi 2.4g/5g/6g channel distribution
- Notes on MySQL related knowledge points (startup, index)
- Development mode and Prospect of China's IT training industry strategic planning trend report Ⓣ 2022 ~ 2028
- Cognitive fallacy: what is dimensional curse
- How PHP gets all method names of objects
- Après 90 ans, j'ai démissionné pour démarrer une entreprise et j'ai dit que j'allais détruire la base de données Cloud.
猜你喜欢

Redis concludes that the second pipeline publishes / subscribes to bloom filter redis as a database and caches RDB AOF redis configuration files

Goodbye 2021, how do programmers go to the top of the disdain chain?
![[vulnhub shooting range] impulse: lupinone](/img/27/b92eeceefd1c71f19d926bdd1eee8b.jpg)
[vulnhub shooting range] impulse: lupinone

Teach you how to install aidlux (1 installation)

Covariance

Decompile and modify the non source exe or DLL with dnspy

The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)

Notes on MySQL related knowledge points (startup, index)

MySQL——数据库备份

Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
随机推荐
[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]
Let me ask you a question. Have you ever used the asynchronous io of Flink SQL to associate dimension tables in MySQL? I set various settings according to the official website
UC Berkeley proposes a multitask framework slip
What if the Flink SQL client exits and the table is emptied?
Decompile and modify the non source exe or DLL with dnspy
Getting started with postman -- built-in dynamic parameters, custom parameters and assertions
十大券商开户注册安全靠谱吗?有没有风险的?
Base ring tree Cartesian tree
Cognitive fallacy: what is dimensional curse
pivot ROP Emporium
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Advanced technology management - how to examine candidates in the interview and increase the entry probability
使用dnSpy對無源碼EXE或DLL進行反編譯並且修改
2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
Après 90 ans, j'ai démissionné pour démarrer une entreprise et j'ai dit que j'allais détruire la base de données Cloud.
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
Intimacy communication -- [repair relationship] - use communication to heal injuries
WiFi 2.4g/5g/6g channel distribution
Analysis report on the development trend and Prospect of global and Chinese supercontinuum laser source industry Ⓚ 2022 ~ 2027
JS Demo calcule combien de jours il reste de l'année