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. 【ORACLE】使用数据泵的生产环境impd,expdp数据迁移

    ********************************************** ** 原文: blog.csdn.net/clark_xu  徐长亮专栏 **************** ...

  2. Crazy Rows

    Problem You are given an N x N matrix with 0 and 1 values. You can swap any two adjacent rows of the ...

  3. 三个水杯 (bfs)

    给出三个水杯,大小不一,并且只有最大的水杯的水是装满的,其余两个为空杯子.三个水杯之间相互倒水,并且水杯没有标识,只能根据给出的水杯体积来计算.现在要求你写出一个程序,使其输出使初始状态到达目标状态的 ...

  4. Android学习----异常(2):Please ensure that adb is correctly located at &#39; ... &#39;

    打开任务管理器,在后台进程中找到 kadb,结束这个进程,重新启动eclipse.

  5. Appium在手机浏览器使用滑屏Not yet implemented解决办法。

    在手机浏览器使用swipe.scroll等手机特有行为时,因为默认context是WEBVIEW,所有一定要切换回NATIVE_APP才可以使用. python: driver.switch_to.c ...

  6. POJ 3299 Humidex(简单的问题)

    [简要题意]:什么是温度,湿度--,之间的转换.. [分析]:式已被赋予. // 252k 0Ms /* 当中exp表示的是求e的x次幂 解法就直接依据题目中的公式解决就好!! */ #include ...

  7. GitFlow使用说明

    ———————安装--------------- $ git clone --recursive git://github.com/nvie/gitflow.git $ cd gitflow $ [s ...

  8. C/S模式开发中如何利用WebBrowser控件制作导航窗体

    原文:C/S模式开发中如何利用WebBrowser控件制作导航窗体 转自: CSDN 相信不少同学们都做过MIS系统的开发,今天这里不讨论B/S模式开发的问题.来谈谈winform开发.用过市面上常见 ...

  9. Asp.net MVC + EF + Spring.Net 项目实践(二)

    这一篇主要介绍数据库和entity framework集成 1. 先创建数据库,很简单的几张表,但也涉及了一些主外键关系.联合主键等,关系图如下(DB脚本在最后) 2. 打开VS,现在建立Model实 ...

  10. 吞吐量(Throughput)、QPS、并发数、响应时间(RT)对系统性能的影响

    首先对吞吐量().QPS.并发数.响应时间(RT)几个概念一直比较模糊,也不知道哪些指标可以较好的衡量系统的性能.今天特意查了些资料做一些记录:首先看一些概念(来自百度百科) 1. 响应时间(RT) ...