当前位置:网站首页>ACM longest non-descent subsequence problem
ACM longest non-descent subsequence problem
2022-08-09 11:44:00 【catch a ponytail girl】
Given a string of numbers, find its longest non-descending subsequence
This problem is a classic dp linear problem, define a three-dimensional array, a[i][1] represents the value, a[i][2] represents the length of the longest subsequence from i to n, and a[i][3] represents the position of the number following the i subsequence.
#includeusing namespace std;int a[100][10],k,l;int main(){int n;cin>>n;for(int i=1;i<=n;i=i+1){cin>>a[i][1];a[i][2]=1;a[i][3]=0;}for(int i=n-1;i>=1;i=i-1){k=0;l=0;for(int j=i+1;j<=n;j=j+1)if((a[j][1]>a[i][1])&&a[j][2]>l){k=j;l=a[j][2];}if(l>0){a[i][2]=l+1;a[i][3]=k;}}k=1;for(int i=1;i<=n;i=i+1)if(a[i][2]>a[k][2])k=i;cout<<"max= "< 边栏推荐
- [现代控制理论]2_state-space状态空间方程
- ACM最长不下降子序列问题
- [现代控制理论]6_稳定性_李雅普诺夫_Lyapunov
- PTA习题 分类统计字符个数(C)
- PTA 计算天数
- ICML 2022 | Out-of-Distribution Detection with Deep Nearest Neighbors
- mysql参数学习----max_allowed_packet
- 双向链表的各种操作
- LeetCode_单调栈_中等_456.132 模式
- This application has no explicit mapping for /error, so you are seeing this as a fallback
猜你喜欢

win10 outlook邮件设置

x86 Exception Handling and Interrupt Mechanism (1) Overview of the source and handling of interrupts

win10右键文件,一直转圈

人体解析(Human Parse)开源数据集整理

proto3-2语法

【C language】动态数组的创建和使用
How tall is the B+ tree of the MySQL index?

Semaphore SIGCHLD use, how to make the parent that the child performs over, how to make the distinction between multiple child processes. The end

enum in c language

【精华文】C语言结构体特殊情况分析:结构体指针 / 基本数据类型指针,指向其他结构体
随机推荐
链表基本操作(详解)
This application has no explicit mapping for /error, so you are seeing this as a fallback
[工程数学]1_特征值与特征向量
PTA 找出不是两个数组共有的元素
PTA 计算天数
redis缓存如何保证数据一致性
[现代控制理论]6_稳定性_李雅普诺夫_Lyapunov
富媒体在客服IM消息通信中的秒发实践
Open3D point cloud average point spacing evaluation
[现代控制理论]3_Phase_portrait 相图 相轨迹
获取url地址中问号后参数(即使是iframe也可以)
x86 exception handling and interrupt mechanism (2) interrupt vector table
es6对象迭代器iterator
百钱买鸡(一)
OC-块对象
PAT1007
End-to-End Object Detection with Fully Convolutional Network学习笔记
PTA习题 阶梯电价(C)
使用.NET简单实现一个Redis的高性能克隆版(四、五)
[现代控制理论]2_state-space状态空间方程