SZU : A11 Sequence
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的更多相关文章
- SystemVerilog Assertion 设计、调试、测试总结(3)
上两篇主要是讲述断言的概念,基本语法,总结等等 这一篇主要是以PPT的形式展示各个场景下关于断言的应用. 为了在设计中加入断言的功能,因此需要写一个DUT.如下: `define `define fr ...
- hdu 5504 GT and sequence
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5504 GT and sequence Time Limit: 2000/1000 MS (Java/O ...
- [Oracle][DATAGUARD] LOGICAL STANDBY环境里,有些SEQUENCE无法应用,导致Primary和Standby无法同期
今天遇到了一个客户,问题是这样的,客户构筑了一个RACtoRAC的 LOGICAL STANDBY环境.并用EM在监视同期情况,发现EM页面上55115和55116这两个SEQUENCE一直在应用. ...
- oracle SEQUENCE 创建, 修改,删除
oracle创建序列化: CREATE SEQUENCE seq_itv_collection INCREMENT BY 1 -- 每次加几个 STA ...
- Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等
功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...
- DG gap sequence修复一例
环境:Oracle 11.2.0.4 DG 故障现象: 客户在备库告警日志中发现GAP sequence提示信息: Mon Nov 21 09:53:29 2016 Media Recovery Wa ...
- Permutation Sequence
The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- [LeetCode] Sequence Reconstruction 序列重建
Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. Th ...
- [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...
随机推荐
- ES6 扫盲
原文地址:ECMAScript 6 扫盲--小胡子 1. let.const 和 block 作用域 let 允许创建块级作用域,ES6 推荐在函数中使用 let 定义变量,而非 var: var a ...
- handlebar的一些用法——个人使用总结
handlebar的一些用法 概述与介绍 Handlebars 是 JavaScript 一个语义模板库,通过对view和data的分离来快速构建Web模板.它采用"Logic-less t ...
- Flex列在一个表格式的数字值
1.问题背景 一般的.表格中展示的比率.对照率的处理是:保留两位小数,并向上保留 2.实现实例 <? xml version="1.0" encoding="utf ...
- 项目中经常使用的JS方法汇总,非常有用
// 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1- ...
- mysql_navicat_快捷键
快捷键能节省很多时间,之前一直研究oracle,plsql有自定义自动补全, 比如 sf 直接回车 可以出现 select * from 等等(参照http://www.cnblogs.com/cph ...
- Codeforces 328B-Sheldon and Ice Pieces(馋)
B. Sheldon and Ice Pieces time limit per test 1 second memory limit per test 256 megabytes input sta ...
- Team City的安装1
持续集成工具 Team City的安装 前两个月很大一部分精力投入在做部门的持续集成,从概念的了解和工具的选型,再到安装,部署,操作,到最后的真实项目持续集成应用的上线,写了一份手册,包括安装,配置, ...
- CSS3+HTML5特效4 - 横向无缝滚动
先看例子 This is a test 1. This is a test 2. This is a test 3. This is a test 4. This is a test 5. This ...
- 只显示年月的js时间控件 纯手写
<style> #date { text-align: center; } .td { cursor: pointer; } </style> <script> f ...
- Ubuntu下的用户和权限(二)
五.chown.chgrp命令 从名字就能够猜測他们是干嘛的,可是这两个命令须要root权限. chown命令的格式为:chown user:group file 中间的user : group三项 ...