题目链接:
http://codeforces.com/contest/702
A. Maximum Increase
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
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 subarraystrictly greater than previous.
Input
The first line contains single positive integer n (1 ≤ n ≤ 105) — the number of integers.
The second line contains n positive integersa1, a2, ..., an (1 ≤ ai ≤ 109).
Output
Print the maximum length of an increasing subarray of the given array.
Examples
Input
5 1 7 2 11 15
Output
3
Input
6 100 100 100 100 100 100
Output
1
Input
3 1 2 3
Output
3
题目大意: n个数求最长的连续子序列
思路:直接for一遍就好,前后比较一下
#include <bits/stdc++.h>
using namespace std;
int num[111111];
int main()
{
int n;
while (~scanf("%d",&n))
{
for (int i = 0 ; i < n ; i++ )
{
scanf("%d",&num[i]);
}
int res = 0;
int temp = 1;
for (int i = 1 ; i < n ; i++ )
{
if (num[i] > num[i-1])
{
temp++;
}
else
{
if (temp > res)
{
res = temp;
}
temp = 1;
}
}
if (temp > res)
{
res = temp;
}
printf("%d\n",res);
}
}
B. Powers of Two
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input