Description

We are given a integer sequence, your job is find the length of the longest contiguous subsequence that is strictly increasing or strictly decreasing.

Input

  • First number , represent how many test cases.
  • For each test case the first number is .
  • Then  positive integers are followed, all of them are less than 101.

Output

For each test case output the answer in one line.

Sample Input

3
3 1 1 1
3 1 2 3
4 4 3 2 1

Sample Output

1
3
4 思路: 用2个数组存取递增递减序列,并且浪费点空间节省效率的方法去做。
 #include<stdio.h>
int main()
{
int i,j,test,num,len,A[],B[],C[];
scanf("%d",&test);
for(i=;i<test;i++)
{
scanf("%d",&num);
for(j=;j<num;j++)
scanf("%d",&C[j]);
A[]=;
B[]=;
for(j=;j<num;j++)
{
if(C[j]>C[j-])
{
A[j]=A[j-]+;
B[j]=;
}
if(C[j]<C[j-])
{
A[j]=;
B[j]=B[j-]+;
}
if(C[j]==C[j-]){
A[j]=;
B[j]=;
}
}
for(j=,len=;j<num;j++)
{
if(A[j]>len) len=A[j];
if(B[j]>len) len=B[j];
}
printf("%d\n",len);
}
return ;
}
 

SZU : A11 Sequence的更多相关文章

  1. SystemVerilog Assertion 设计、调试、测试总结(3)

    上两篇主要是讲述断言的概念,基本语法,总结等等 这一篇主要是以PPT的形式展示各个场景下关于断言的应用. 为了在设计中加入断言的功能,因此需要写一个DUT.如下: `define `define fr ...

  2. hdu 5504 GT and sequence

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5504 GT and sequence Time Limit: 2000/1000 MS (Java/O ...

  3. [Oracle][DATAGUARD] LOGICAL STANDBY环境里,有些SEQUENCE无法应用,导致Primary和Standby无法同期

    今天遇到了一个客户,问题是这样的,客户构筑了一个RACtoRAC的 LOGICAL STANDBY环境.并用EM在监视同期情况,发现EM页面上55115和55116这两个SEQUENCE一直在应用. ...

  4. oracle SEQUENCE 创建, 修改,删除

    oracle创建序列化: CREATE SEQUENCE seq_itv_collection            INCREMENT BY 1  -- 每次加几个              STA ...

  5. Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等

    功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...

  6. DG gap sequence修复一例

    环境:Oracle 11.2.0.4 DG 故障现象: 客户在备库告警日志中发现GAP sequence提示信息: Mon Nov 21 09:53:29 2016 Media Recovery Wa ...

  7. Permutation Sequence

    The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  8. [LeetCode] Sequence Reconstruction 序列重建

    Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. Th ...

  9. [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列

    Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...

随机推荐

  1. Linux下的变化的主机名步骤

    Linux下变化的主机名gpdb 步骤1.执行vi /etc/sysconfig/network命令 NETWORKING=yesHOSTNAME=gpdb 第二步.执行hostname gpdb令 ...

  2. 独立博客网站FansUnion.cn操作2多年的经验和教训以及未来计划

    今天,我把运营了2年的独立博客站点FansUnion给"归零"了.    2012年6月.我成功搭建了自己的博客站点FansUnion.cn,这是因为自己的不懈努力和时代发展成就的 ...

  3. Redis源代码分析(十一年)--- memtest内存测试

    今天,我们继续redis源代码test下测试在封装中的其它文件.今天读数memtest档,翻译了,那是,memory test 存储器测试工具..可是里面的提及了非常多东西,也给我涨了非常多见识,网上 ...

  4. oracle_查询Oracle正在执行和执行过的SQL语句

    ---正在执行的select a.username, a.sid,b.SQL_TEXT, b.SQL_FULLTEXT  from v$session a, v$sqlarea b where a.s ...

  5. 转载使用Flurl制作可复用的分页组件

    使用Flurl制作可复用的分页组件 使用ASP.NET MVC查询时,一直使用MvcPaging组件,虽然需要自定义MvcPaging.Pager才能达到我想要的效果,但在没有较好的URL库时,还是这 ...

  6. java传值和通过引用传递

    第一次使用int实验: public class TTEST { private static List<UserEntity> mList = new LinkedList<Use ...

  7. poj 1556 zoj1721 BellmanFord 最短路+推断直线相交

    http://poj.org/problem?id=1556 The Doors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions ...

  8. AngularJS之使用服务封装可复用代码

    创建服务组件 在AngularJS中创建一个服务组件很简单,只需要定义一个具有$get方法的构造函数, 然后使用模块的provider方法进行登记: //定义构造函数 var myServicePro ...

  9. C#中如何获取系统环境变量

    原文:C#中如何获取系统环境变量 C#中获取系统环境变量需要用到Environment Class.其中提供了有关当前环境和平台的信息以及操作它们的方法.该类不能被继承. 以下代码得到%systemd ...

  10. Pointers to classes (From the note of my firend)

     Pointers to classes Objects can also be pointed to by pointers: Once declared, a class becomes a ...