Educational Codeforces Round 15 A dp
1 second
256 megabytes
standard input
standard output
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 题意:连续的最长上升子序列的长度
题解:dp[i]表示以a[i]结尾的 连续的最长上升子序列的长度
/******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<algorithm>
#include<queue>
#include<cmath>
#define ll __int64
#define PI acos(-1.0)
#define mod 1000000007
using namespace std;
int n;
int a[];
int dp[];
int ans=;
int main()
{
scanf("%d",&n);
int ans=;
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
dp[]=;
ans=;
for(int i=;i<=n;i++)
{
if(a[i]>a[i-])
{
dp[i]=dp[i-]+;
ans=max(ans,dp[i]);
}
else
dp[i]=;
}
cout<<ans<<endl;
return ;
}
Educational Codeforces Round 15 A dp的更多相关文章
- Educational Codeforces Round 26 D dp
D. Round Subset time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- codeforces Educational Codeforces Round 16-E(DP)
题目链接:http://codeforces.com/contest/710/problem/E 题意:开始文本为空,可以选择话费时间x输入或删除一个字符,也可以选择复制并粘贴一串字符(即长度变为两倍 ...
- Codeforces Educational Codeforces Round 15 C. Cellular Network
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- 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 ...
- Educational Codeforces Round 60 D dp + 矩阵快速幂
https://codeforces.com/contest/1117/problem/D 题意 有n个特殊宝石(n<=1e18),每个特殊宝石可以分解成m个普通宝石(m<=100),问组 ...
- Educational Codeforces Round 15 C. Cellular Network(二分)
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 15 C 二分
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Educational Codeforces Round 15 E - Analysis of Pathes in Functional Graph
E. Analysis of Pathes in Functional Graph time limit per test 2 seconds memory limit per test 512 me ...
- Codeforces Educational Codeforces Round 15 D. Road to Post Office
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...
随机推荐
- ZOJ 3645 BiliBili 高斯消元 难度:1
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4835 由题意,有: (x1-x11)^2 + (x2-x12)^2 ... = ...
- 使用ASP.Net WebAPI构建REST服务(二)——路由
REST并没有像传统的RPC服务那样显式指定了服务器函数的访问路径,而是将URL根据一定的规则映射为服务函数入口,这个规则就称之为路由.Asp.Net WebAPI的路由方式和Asp.Net MVC是 ...
- [开发笔记]-使用bat命令来快速安装和卸载Service服务
一般我们在编写完Service服务程序后,都是通过cmd命令提示窗口来安装或卸载服务,但频繁的在cmd窗口中去“拼”文件的路径着实让人“不能忍”.所以,我们需要一钟“更快捷”的方式来进行安装或者卸载操 ...
- C++,1....n中随机等概率的输出m个不重复的数(假设n远大于m)。
#include <stdlib.h> #include <time.h> knuth(int n, int m) { srand((unsigned )); ; i < ...
- IOS 导航栏属性设置
IOS 7 以上系统导航栏: [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; // 返回按钮颜色 [UINaviga ...
- Spark的编译
由于Spark的运行环境的多样性,如可以运行在hadoop的yarn上,这样就必须要对Spark的源码进行编译.下面介绍一下Spark源码编译的详细步骤: 1.Spark的编译方式:编译的方式可以参考 ...
- Tarjan算法求有向图的强连通分量
算法描述 tarjan算法思想:从一个点开始,进行深度优先遍历,同时记录到达该点的时间(dfn记录到达i点的时间),和该点能直接或间接到达的点中的最早的时间(low[i]记录这个值,其中low的初始值 ...
- 关于binary search的一点解惑
在写binary search时对于mid的计算我最开始使用的是 mid = (low + high)/2; 后来看到在很多的实现为 mid = low + (high - low)/2; 想了一下两 ...
- csharp_ToJson的正确写法
网上搜的,但有问题,已经改好...现在这个是正确的 public static string ToJson(DataTable dt, string jsonName) { ...
- OLAP的一些知识——接下去的项目需要的背景
1.维是人们观察主题的特定角度,每一个维分别用一个表来描述,称为“维表”(Dimension Table),它是对维的详细描述. 2.事实表示所关注的主题,亦由表来描述,称为“事实表”(Fact Ta ...