#include<iostream>
using namespace std ;
const int N=;
int f[N];
int a[N];
int main() {
int n;
cin>>n;
int res=;
for(int i=; i<=n; i++) cin>>a[i];
for(int i=; i<=n; i++) {
f[i]=a[i];
for(int j=; j<i; j++) {
if(a[i]>a[j]) f[i]=max(f[i],f[j]+a[i]);
}
res=max(res,f[i]);
}
cout<<res<<endl;
return ;
}

AcWing 1016. 最大上升子序列和的更多相关文章

  1. AcWing 799. 最长连续不重复子序列

    网址  https://www.acwing.com/solution/AcWing/content/2069/ 题目描述给定一个长度为n的整数序列,请找出最长的不包含重复数字的连续子序列,输出它的长 ...

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

    #include<iostream> using namespace std ; ; int n; int a[N]; int b[N]; int f[N][N]; //f[i][j] / ...

  3. AcWing 799. 最长连续不重复子序列 双指针(一般先写一个朴素暴力的做法,然后看两个指针直接是否存在单调关系,如果存在,就想方法优化)

    https://www.acwing.com/problem/content/801/ #include<bits/stdc++.h> using namespace std ; int ...

  4. AcWing 896. 最长上升子序列 II

    #include<iostream> #include<algorithm> #include<vector> using namespace std; int m ...

  5. AcWing 895. 最长上升子序列

    //设上升序列的最后一个数字为第i个,那么就以第i-1个位分类标准, //i-1可以没有,也可以是在数组中下标为1,下标为2 //一直到下标为i-1的数字 #include <iostream& ...

  6. AcWing 897. 最长公共子序列

    #include <iostream> #include <algorithm> using namespace std; ; int n, m; char a[N], b[N ...

  7. [AcWing 2816] 判断子序列

    点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], b[N]; int mai ...

  8. [AcWIng 799] 最长连续不重复子序列

    点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], s[N]; int mai ...

  9. AcWing 314. 低买 (线性DP)打卡

    题目:https://www.acwing.com/problem/content/316/ 题意:求一个最长单调递减子序列,然后并且求方案数,如果序列完全一样就不要了 思路:我们肯定时修改LIS,我 ...

随机推荐

  1. javascript生成指定位数的随机数

    <script type="text/javascript"> document.write("请输入要生成随机数的位数:"); // digit是 ...

  2. 通过vsphere给esxi添加本地硬盘

    公司ESXi服务器的硬盘空间不够使用,现在新加了一块硬盘在ESxi服务器上.在服务器上添加完硬盘后,在Vsphere上是看不到新加硬盘的. 下面我们来通过虚拟机模拟该情况,先添加一块硬盘.如下图: 在 ...

  3. 获取redis实例绑定cpu的情况

    redis是一个单线模型的nosql类型的数据库,而目前接触到的服务器大都是多核的,比如8c,16c,32c,64c等等.为了充分利用主机,在一台主机上必然会部署多个redis实例,默认情况cpu会随 ...

  4. LNMP环境配置(2)

    php-fpm配置,Nginx配置 Nginx配置 默认虚拟主机 修改主配置文件 # vi  /usr/local/nginx/conf/nginx.conf 在最后 } 符号上面写入  includ ...

  5. UI设计的定义和view、viewgroup及其一些常用属性

    1.uI设计 UI设计就是用户界面设计,比如QQ登录界面.聊天界面等,进行UI设计将会用到View和Viewgroup. 2.view 在安卓中可以理解为视图,在安卓中占用一块矩形区域,负责提供主件绘 ...

  6. sql多字段分组排序显示全部数据

    建表sql CREATE TABLE `tbl_demo` ( `id` ) COLLATE utf8_bin NOT NULL, `payer_name` ) COLLATE utf8_bin DE ...

  7. Just a Hook HDU - 1698Just a Hook HDU - 1698 线段树区间替换

    #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> us ...

  8. js打印前几天或后几天的日期

    <script language="JavaScript" type="text/javascript">function dater(sj){ v ...

  9. burpsuite抓取小程序的数据包(指定DNS)

    目标:burpsuite抓取微信小程序的数据包,而且该系统需指定DNS!否则无法访问! 大家都知道小程序是https传输的,所以手机端是需要安装burp证书的. 已忽略安装证书的步骤,可自己百度搜索, ...

  10. C++->10.3.6.设有两个按升序排列的二进制文件a和b,将他们合并成一个新的升序二进制数据文件file。

    #include<iostream.h> #include<stdlib.h> #include<string.h> #include<fstream.h&g ...