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. 学习java的第十天

    一.今日收获 1.java完全学习手册第二章2.9程序流程控制中的选择结构与顺序结构的例题 2.观看哔哩哔哩上的教学视频 二.今日问题 1.例题的问题不大,需要注意大小写,新的语句记忆不牢 2.哔哩哔 ...

  2. Shell 管道指令pipe

    目录 管道命令pipe 选取命令 cut.grep cut 取出需要的信息 grep 取出需要行.过滤不需要的行 排序命令 sort.wc.uniq sort 排序 假设三位数,按十位数从小到大,个位 ...

  3. 论文解读(GraRep)《GraRep: Learning Graph Representations with Global Structural Information》

    论文题目:<GraRep: Learning Graph Representations with Global Structural Information>发表时间:  CIKM论文作 ...

  4. Scala和Java的List集合互相转换

    import java.util import scala.collection.mutable /** * 集合互相转换 */ object ScalaToJava { def main(args: ...

  5. Vue面试专题(未完)

    1.谈一下你对MVVM原理的理解 传统的 MVC 指的是,用户操作会请求服务端路由,路由会调用对应的控制器来处理,控制器会获取数 据.将结果返回给前端,页面重新渲染.   MVVM :传统的前端会将数 ...

  6. openwrt装载固件

    方法1. 确定串口号以后(在设备管理器可以查看) 打开SecureCRT软件,选择串口,设置合适的波特率(我用的115200),然后快速连接, 板子通电启动,在启动的时候会提示按任意键中断,这时按下任 ...

  7. android studio 编译NDK android studio 生成.so文件

    详细配置使用请移步:https://www.jianshu.com/p/4c7d9a10933b android studio NDK 编译 第一步: app/build.gradle下面 添加代码: ...

  8. 转 Android中Activity的启动模式(LaunchMode)和使用场景

    转载请注明出处:http://blog.csdn.net/sinat_14849739/article/details/78072401本文出自Shawpoo的专栏我的简书:简书 一.为什么需要启动模 ...

  9. spring boot 启动卡半天

    测试服务器到期,把环境切了,早上过来 ios 和 安卓 都说 测试环境连不上,ps -ef | grep app.jar 查看了一下进程,发现没有启动,于是 重新打包.部署,一顿骚操作后,监控启动日志 ...

  10. 【保姆级教程】Ubuntu18.04+Geforce 980Ti+安装CUDA10.2+Cudnn

    首先感谢师兄的博客!前半部分按照这个照做没有问题! https://www.bilibili.com/read/cv9162965/ 第一步:下载CUDA 在官网下载,查询自己的GPU型号对应的CUD ...