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 }

最新文章

  1. ---bind 配置
  2. select 嵌套
  3. 发短信的简单实现——C#版
  4. ActiveMQ的使用笔记(基本实现原理)
  5. 改变tableView索引颜色
  6. Java学习-012-文件删除实例及源代码
  7. android 学习随笔二十八(应用小知识点小结 )
  8. ubuntu 14.04 apache maven 安装
  9. 最短路径—Dijkstra算法和Floyd算法【转】
  10. 基于 HTML5 的数据存储
  11. geoserver扫盲 openlayers相关
  12. 【狼】unity3d collision获取碰撞的点的位置
  13. javamail发送二进制流附件的问题
  14. 通过Manifest的配置信息实现页面跳转,及总结
  15. Hbase shell 中能否通过filter实现的高级查询
  16. (原创)用JAX-WS+Spring实现简单soap规范的webservice
  17. svn服务器的搭建与使用一
  18. Tcl与Design Compiler (五)——综合库(时序库)和DC的设计对象
  19. 封装、property特性及绑定与非绑定方法
  20. 学习下知然网友写的taskqueue

热门文章

  1. Shell 管道指令pipe
  2. day18定时任务
  3. 学习Vue源码前的几项必要储备(一)
  4. 【leetcode】451.&#160;Sort Characters By Frequency
  5. maven常用Java配置
  6. 京东消息中间件JMQ(转)
  7. 【Spring Framework】Spring IOC详解及Bean生命周期详细过程
  8. BDD自动化测试框架cucumber(1): 最基本的demo
  9. Jenkins远程发布制品
  10. pipeline 步骤