cf702A Maximum Increase
You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.
A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this subarray strictly greater than previous.
The first line contains single positive integer n (1 ≤ n ≤ 105) — the number of integers.
The second line contains n positive integers a1, a2, ..., an (1 ≤ ai ≤ 109).
Print the maximum length of an increasing subarray of the given array.
5
1 7 2 11 15
3
6
100 100 100 100 100 100
1
3
1 2 3
3
求出最长上升子串长度
真是逗逼。。写了<和>的情况忘记搞=了
然后被x。。
幸好不记分
哎毕竟是老了
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void write(LL a)
{
if (a<){printf("-");a=-a;}
if (a>=)write(a/);
putchar(a%+'');
}
inline void writeln(LL a){write(a);printf("\n");}
int n,x,tot,ans;
int a[];
int main()
{
n=read();
for(int i=;i<=n;i++)a[i]=read();
x=a[];tot=;ans=;
for (int i=;i<=n;i++)
{
if (a[i]>x)x=a[i],tot++;
else if (a[i]<=x)x=a[i],tot=;
ans=max(ans,tot);
}
printf("%d\n",ans);
}
cf702A
cf702A Maximum Increase的更多相关文章
- Codeforces Educational Codeforces Round 15 A. Maximum Increase
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
- codeforces 702A A. Maximum Increase(水题)
题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...
- CodeForces 702 A Maximum Increase (贪心,高效算法)
题意:给定 n 个数,问你连续的最长的序列是几个. 析:从头扫一遍即可. 代码如下: #include <cstdio> #include <string> #include ...
- CodeForces 702A Maximum Increase
简单$dp$. 如果$a[i]>a[i-1]$,那么$dp[i]=dp[i-1]+1$.否则,$dp[i]=1$.答案为$dp[i]$中的最大值. #pragma comment(linker, ...
- Codeforces 702A Maximum Increase(dp)
题目链接:http://codeforces.com/problemset/problem/702/A 题意: 给你N个数,a[0], a[1], a[2], ....., a[n-1],让你找出最长 ...
- Codeforces - 702A - Maximum Increase - 简单dp
DP的学习计划,刷 https://codeforces.com/problemset?order=BY_RATING_ASC&tags=dp 遇到了这道题 https://codeforce ...
- Codeforces702A - Maximum Increase【尺取】
题意: 求一个连续的最长子序列长度: 思路: 没看仔细还wa1了-以为LIS- 然后写了尺取吧...= =太不仔细了.不过收获是LIS特么写挫了然后看了学长的blog<-点我- 题目的挫code ...
- Educational Round 15
A题Maximum Increase 大水题.最长连续递增子序列有多长. #include <cstdio> #include <algorithm> using namesp ...
- Educational Codeforces Round 15 A dp
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- instanceof的用法②
其实这个问题以前也困扰过我.我个人理解的一个应用场合就是,当你拿到一个对象的引用时(例如参数), 你可能需要判断这个引用真正指向的类.所以你需要从该类继承树的最底层开始,使用instanceof操作符 ...
- Signalr简单入门,使用注意点
注意点:1,创建proxy代理时候,继承了hub的类,方法名在js中,同名,但是默认首字母是小写,2,js中代理毁掉方法的名称和继承了hub的类的方法中的Clients.All.的对象名称要一致(名称 ...
- oracle 导出导入数据
在window的运行中输出cmd,然后执行下面的一行代码, imp blmp/blmp@orcl full=y file=D:\blmp.dmp OK,问题解决.如果报找不到该blmp.dmp文件,就 ...
- A除以B_2
本题要求计算A/B,其中A是不超过1000位的正整数,B是1位正整数.你需要输出商数Q和余数R,使得A = B * Q + R成立. 输入格式: 输入在1行中依次给出A和B,中间以1空格分隔. 输出格 ...
- Web性能压力测试之Webbench使用详解
Webbench是知名的网站压力测试工具,它是由Lionbridge公司(http://www.lionbridge.com)开发.Webbench能测试处在相同硬件上,不同服务的性能以及不同硬件上同 ...
- app图标和启动页设置
弄了一下午,终于把iOS中图标的设置和启动页的设置弄明白了.我想以后再也不会浑了. 进入正题: 一:apple 1).iPhone4s 3.5寸屏,也就是640*960,但在模拟器上正常用的是320* ...
- iOS中webView加载URL需要处理特殊字符
今天在项目中遇到webView加载URL时,因为URL中有特殊字符,导致页面无法加载,而且在- (BOOL)webView:(UIWebView )webView shouldStartLoadWit ...
- Git 基础再学习之:git checkout -- file
首先明白一下基本概念和用法,这段话是从前在看廖雪峰的git教程的时候摘到OneNote的 准备工作: 新建了一个learngit文件夹,在bash中cd进入文件夹,用以下命令创建一个仓库. $ git ...
- 【转】ASP.NET MVC 入门教程列表
ASP.NET MVC小论 2008-12-04 11:11 by T2噬菌体, 8052 visits, 网摘, 收藏, 编辑 摘要:ASP.NET MVC作为微软官方的.NET平台下MVC解决方案 ...
- 赋值,copy和deepcopy
python的复制,拷贝,和深拷贝. >>> a=[23,3]>>> b=a>>> b.append(234)>>> a[23, ...