当前位置:网站首页>The longest ascending subsequence model acwing 1017. The glider wing of the strange thief Kidd
The longest ascending subsequence model acwing 1017. The glider wing of the strange thief Kidd
2022-07-27 11:13:00 【T_ Y_ F666】
Longest ascending subsequence model AcWing 1017. Kidd's glider
Original link
Algorithm tags
DP linear DP Longest ascending subsequence
Ideas 
Code
#include<bits/stdc++.h>
#define int long long
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>=b;--i)
using namespace std;
const int N = 105, INF = 0x3f3f3f3f;
int f[N], a[N];
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=read();
while(t--){
int n=read();
rep(i, 1, n+1){
a[i]=read();
}
int ans=0;
// a[i] End point Pass from left to right a[j] The longest distance
rep(i, 1, n+1){
f[i]=1;
rep(j, 1, i){
if(a[j]<a[i]){
f[i]=max(f[i], f[j]+1);
}
}
ans=max(ans, f[i]);
}
// a[i] End point Pass from right to left a[j] The longest distance
Rep(i, n, 0){
f[i]=1;
Rep(j, n, i+1){
if(a[j]<a[i]){
f[i]=max(f[i], f[j]+1);
}
}
ans=max(ans, f[i]);
}
printf("%lld\n", ans);
}
}
Originality is not easy.
Reprint please indicate the source
If it helps you Don't forget to praise and support 
边栏推荐
- How to build a real-time development platform to deeply release the value of enterprise real-time data?
- SQL Server2000 database error
- Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
- Verilog implementation of ECG signal acquisition, storage and transmission system based on FPGA
- The influence of the number of non-zero values in the picture on Classification
- 基于FPGA的ECG信号采集,存储以及传输系统verilog实现
- IMG SRC is empty or SRC does not exist, and the picture has a white border
- Cancer DDD
- Derivation of the detailed expansion sto overlap integrals
- Redis+caffeine two-level cache enables smooth access speed
猜你喜欢

Use__ slots__ And__ dict__ To save space (it's simply a qualitative leap, and leetcode's personal test is effective)

迭代次数的差异与信息熵

涌现与形态的局部差异和整体差异

Redis high availability principle

Play with the cluster configuration center and learn about the Taier console

XXX packages are looking for funding run 'NPM fund' for details solutions

Data assets are king. How to analyze the relationship between enterprise digital transformation and data asset management?

Real time development platform construction practice, in-depth release of real-time data value - 04 live broadcast review

最长上升子序列模型 AcWing 272. 最长公共上升子序列

Openatom openharmony sub forum, see you today at 14:00! Wonderful release of memorabilia attached
随机推荐
MIMO array 3D imaging technology based on mobile terminal
Local and overall differences between emergence and morphology
C语言 2:求三数字最大值,求三数字中间值,编写程序步骤
基于FPGA的ECG信号采集,存储以及传输系统verilog实现
What is the mystery of the gate of the meta universe?
解决 ImportError: cannot import name 'abs' 导入tensorflow报错
XXX packages are looking for funding run 'NPM fund' for details solutions
Application scenarios, key technologies and network architecture of communication perception integration
Verilog implementation of ECG signal acquisition, storage and transmission system based on FPGA
泰山OFFICE技术讲座:缩放比例与打开文件
Using skills of word
洛谷P1896 互不侵犯
8 find subsequences with a maximum length of K
How to assemble a registry
Chunjun supports DDL conversion and automatic execution of heterogeneous data sources - dtmo 02 review (including course playback + courseware)
The article will not keep VIP charges all the time. It will be open for a period of time
6 find the smallest letter larger than the target letter
Analysis of C language pointer function and function pointer
学习笔记-minio
Neural network learning notes