当前位置:网站首页>[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;
} 边栏推荐
- Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
- Functions and differences between static and Const
- DR882-Qualcomm-Atheros-QCA9882-2T2R-MIMO-802.11ac-Mini-PCIe-Wi-Fi-Module-5G-high-power
- Pengcheng cup Web_ WP
- Great gods, I want to send two broadcast streams: 1. Load basic data from MySQL and 2. Load changes in basic data from Kafka
- treevalue——Master Nested Data Like Tensor
- Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
- JS notes (III)
- How PHP drives mongodb
- Compilation Principle -- syntax analysis
猜你喜欢

MySQL——数据库备份

TiDB 之 TiCDC6.0 初体验

The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation

Morning flowers and evening flowers

Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy

gslb(global server load balance)技術的一點理解

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)

Minio deployment

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

UC Berkeley proposes a multitask framework slip
随机推荐
The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation
仿网易云音乐小程序
MySQL——JDBC
Qualcomm platform WiFi -- P2P issue
Common SQL sets
17 websites for practicing automated testing. I'm sure you'll like them
Control loop of program (while loop)
Global and Chinese market of gallic acid 2022-2028: Research Report on technology, participants, trends, market size and share
Advanced technology management - how to examine candidates in the interview and increase the entry probability
treevalue——Master Nested Data Like Tensor
WFC900M-Network_ Card/Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-900M-high-power-Mini-PCIe-Wi-Fi-Mod
MySQL——SQL注入问题
Is it OK for fresh students to change careers to do software testing? The senior answered with his own experience
Remember the experience of automatically jumping to spinach station when the home page was tampered with
Yyds dry inventory Chapter 4 of getting started with MySQL: data types that can be stored in the data table
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Morning flowers and evening flowers
Cognitive fallacy: Wittgenstein's ruler
Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]