当前位置:网站首页>[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;
} 边栏推荐
- What should the future of the Internet be like when Silicon Valley employees flee the big factory and rush to Web3| Footprint Analytics
- 2022-2-14 acwing1027 grid access
- Sed、Awk
- Preliminary understanding of C program design
- Persistence of Nacos
- How PHP gets all method names of objects
- gslb(global server load balance)技术的一点理解
- 常用sql集合
- Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
- Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)
猜你喜欢

Persistence of Nacos

QFileDialog

Getting started with postman -- built-in dynamic parameters, custom parameters and assertions

UC Berkeley proposes a multitask framework slip

仿网易云音乐小程序

Goodbye 2021, how do programmers go to the top of the disdain chain?

90 后,辞职创业,说要卷死云数据库

Mysql - - Index

Nacos common configuration

Yiwen teaches you how to choose your own NFT trading market
随机推荐
C程序设计的初步认识
Getting started with postman -- environment variables and global variables
90 後,辭職創業,說要卷死雲數據庫
Farmersworld farmers world, no faith, how to talk about success?
Investment analysis and prospect trend prediction report of China's boron nitride industry Ⓨ 2022 ~ 2028
Great gods, I want to send two broadcast streams: 1. Load basic data from MySQL and 2. Load changes in basic data from Kafka
Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
Remember the experience of automatically jumping to spinach station when the home page was tampered with
What if the Flink SQL client exits and the table is emptied?
Intimacy communication -- [repair relationship] - use communication to heal injuries
抓包整理外篇——————autoResponder、composer 、statistics [ 三]
Code in keil5 -- use the code formatting tool astyle (plug-in)
4. Data splitting of Flink real-time project
Luogu deep foundation part 1 Introduction to language Chapter 6 string and file operation
[SRS] build a specified version of SRS
What is the content of the securities practice examination?
常用sql集合
Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
Tidb's initial experience of ticdc6.0
Dahua series books