当前位置:网站首页>[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;
} 边栏推荐
- Correlation
- WFC900M-Network_ Card/Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-900M-high-power-Mini-PCIe-Wi-Fi-Mod
- Redis concludes that the second pipeline publishes / subscribes to bloom filter redis as a database and caches RDB AOF redis configuration files
- Collection | pytoch common loss function disassembly
- Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
- Farmersworld farmers world, no faith, how to talk about success?
- The 14th five year plan for the construction of Chinese Enterprise Universities and the feasibility study report on investment Ⓓ 2022 ~ 2028
- Tkinter Huarong Road 4x4 tutorial III
- gslb(global server load balance)技術的一點理解
- Luogu deep foundation part 1 Introduction to language Chapter 7 functions and structures
猜你喜欢

2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions

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

17 websites for practicing automated testing. I'm sure you'll like them

常用sql集合

Decompile and modify the non source exe or DLL with dnspy

Is it OK for fresh students to change careers to do software testing? The senior answered with his own experience

MySQL——索引

Collection | pytoch common loss function disassembly

Covariance

Nacos common configuration
随机推荐
TiDB 之 TiCDC6.0 初体验
2022 high altitude installation, maintenance and removal of examination question bank and high altitude installation, maintenance and removal of examination papers
Remember the experience of automatically jumping to spinach station when the home page was tampered with
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Common SQL sets
Sed、Awk
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)
Farmersworld farmers world, no faith, how to talk about success?
UC Berkeley proposes a multitask framework slip
90 后,辞职创业,说要卷死云数据库
Great gods, I want to send two broadcast streams: 1. Load basic data from MySQL and 2. Load changes in basic data from Kafka
Intimacy communication -- [repair relationship] - use communication to heal injuries
使用dnSpy对无源码EXE或DLL进行反编译并且修改
Service discovery and load balancing mechanism -service
Monkey/ auto traverse test, integrate screen recording requirements
十大券商开户注册安全靠谱吗?有没有风险的?
gslb(global server load balance)技術的一點理解
Global and Chinese market of AC induction motors 2022-2028: Research Report on technology, participants, trends, market size and share
regular expression
A little understanding of GSLB (global server load balance) technology