sequence2

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 677    Accepted Submission(s): 244

Problem Description
Given an integer array bi with a length of n, please tell me how many exactly different increasing subsequences.

P.S. A subsequence bai(1≤i≤k) is an increasing subsequence of sequence bi(1≤i≤n) if and only if 1≤a1<a2<...<ak≤n and ba1<ba2<...<bak.
Two sequences ai and bi is exactly different if and only if there exist at least one i and ai≠bi.
 
Input
Several test cases(about 5)

For each cases, first come 2 integers, n,k(1≤n≤100,1≤k≤n)

Then follows n integers ai(0≤ai≤109)
 
Output
For each cases, please output an integer in a line as the answer.
 
Sample Input
3 2
1 2 2
3 2
1 2 3
 
Sample Output
2
3
 
Source
 
Recommend
hujie
 

Statistic | Submit | Discuss | Note

令{A}_{i}=f({A}_{i})-{A}_{i}A​i​​=f(A​i​​)−A​i​​,然后求一遍最大连续子序列和就能知道最多能增加的值。

 1 #include<stdio.h>
2 #include<algorithm>
3 #include<iostream>
4 #include<stdlib.h>
5 #include<vector>
6 #include<queue>
7 #include<cstdio>
8 #include<string.h>
9 typedef long long ll;
10 using namespace std;
11 ll a[100005];
12 ll b[100005];
13
14 int main(void)
15 {
16 ll n,i,j,k,p,q;
17
18 while(scanf("%lld",&n)!=EOF)
19 { ll tt=0;
20 for(i=0; i<n; i++)
21 {
22 scanf("%lld",&a[i]);
23 tt+=a[i];
24 }
25 for(i=0; i<n; i++)
26 {
27 b[i]=(1890*a[i]+143)%10007-a[i];
28 }
29 ll sum=0;
30 ll cnt=b[0];
31 if(sum<cnt)
32 {
33 sum=cnt;
34 }
35 for(i=1; i<n; i++)
36 {
37 if(b[i-1]>=0)
38 {
39 b[i]+=b[i-1];
40
41 }
42 if(sum<b[i])
43 {
44 sum=b[i];
45 }
46 }
47 if(sum<0)
48 {
49 sum=0;
50 }
51 printf("%d\n",sum+tt);
52 }
53 return 0;
54
55
56 }

hdu-5568SUM (dp)的更多相关文章

  1. hdu 3016 dp+线段树

    Man Down Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  2. HDU 5928 DP 凸包graham

    给出点集,和不大于L长的绳子,问能包裹住的最多点数. 考虑每个点都作为左下角的起点跑一遍极角序求凸包,求的过程中用DP记录当前以j为当前末端为结束的的最小长度,其中一维作为背包的是凸包内侧点的数量.也 ...

  3. HDU 1069 dp最长递增子序列

    B - Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  4. HDU 1160 DP最长子序列

    G - FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  5. hdu 4826(dp + 记忆化搜索)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4826 思路:dp[x][y][d]表示从方向到达点(x,y)所能得到的最大值,然后就是记忆化了. #i ...

  6. HDU 2861 (DP+打表)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2861 题目大意:n个位置,m个人,分成k段,统计分法.S(n)=∑nk=0CknFibonacci(k ...

  7. HDU 2838 (DP+树状数组维护带权排序)

    Reference: http://blog.csdn.net/me4546/article/details/6333225 题目链接: http://acm.hdu.edu.cn/showprobl ...

  8. hdu 5791 (DP) Two

    hdu 5791 Two Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  9. HDU 1069&&HDU 1087 (DP 最长序列之和)

    H - Super Jumping! Jumping! Jumping! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format: ...

  10. hdu 1506(dp求最大子矩阵)

    题意:容易理解... 分析:对于每个单位矩阵,我们先求出连续比它高的最左边的下标假设为l,然后求出比它高的最右边的下标假设为r,然后矩阵的面积就是(r-l+1)*1:我们从左到 右扫一遍,求出每个点的 ...

随机推荐

  1. GIFS服务的使用

    1.安装Samba服务 登录192.168.200.20虚拟机,首先修改主机名,命令如下: [root@nfs-client ~]# hostnamectl set-hostname samba [r ...

  2. 用原生CSS编写动态字体

    HTML部分: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <t ...

  3. 7 — 简单了解springboot中的thymeleaf

    1.官网学习地址 https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html 2.什么是thymeleaf? 一张图看明白: 解读: ...

  4. JVM1 JVM与Java体系结构

    目录 JVM与Java体系结构 虚拟机与Java虚拟机 虚拟机 Java虚拟机 JVM的位置 JVM的整体结构 Java代码执行流程 JVM的架构模型 基于栈的指令级架构 基于寄存器的指令级架构 两种 ...

  5. above, abrupt

    above 近义词: over, beyond, exceeding反义词: below, beneath, under, underneath 有从右往左写的文字,没有从下往上的.above-men ...

  6. Hadoop、Hive【LZO压缩配置和使用】

    目录 一.编译 二.相关配置 三.为LZO文件创建索引 四.Hive为LZO文件建立索引 1.hive创建的lzo压缩的分区表 2.给.lzo压缩文件建立索引index 3.读取Lzo文件的注意事项( ...

  7. Docker学习(五)——Docker仓库管理

    Docker仓库管理     仓库(Repository)是集中存放镜像的地方. 1.Docker Hub       目前Docker官方维护了一个公共仓库Docker Hub.大部分需求都可以通过 ...

  8. 利用unordered_map维护关联数据

    在leetcode上刷339题Evaluate Division(https://leetcode.com/problems/evaluate-division/#/description)时在脑中过 ...

  9. [学习总结]5、Android的ViewGroup中事件的传递机制(二)

    下面是第一篇的连接 Android的ViewGroup中事件的传递机制(一) 关于onInterceptTouchEvent和onTouchEvent的详细解释. 1 public class Mai ...

  10. Linux基础命令---smbpasswd管理samba密码

    smbpasswd smbpasswd指令可以用来修改samba用户的的密码,该指令不仅可以修改本地samba服务器的用户密码,还可以修改远程samba服务器的用户密码. 此命令的适用范围:RedHa ...