题目背景
统计天数
题目描述
炎热的夏日,KC非常的不爽。他宁可忍受北极的寒冷,也不愿忍受厦门的夏天。最近,他开始研究天气的变化。他希望用研究的结果预测未来的天气。
经历千辛万苦,他收集了连续N(1<=N<=10^7)天的最高气温数据。
现在,他想知道最高气温一直上升的最长连续天数。
输入输出格式
输入格式:
*1行:一个整数N。1<=N<=10^7
*2行:N个空格隔开的整数,表示连续N天的最高气温。0<=最高气温<=10^9。
输出格式:
*1行:一个整数,表示最高气温一直上升的最长连续天数。
输入输出样例
输入样例#1: 复制
10 1 2 3 2 4 5 6 8 5 9
输出样例#1: 复制
5
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#define Swap(a,b) a ^= b ^= a ^= b
using namespace std ;
const int MAX = 1e7+10;
const int inf = 0xffffff;
typedef long long LL;
int a[MAX] ;
int ans ;
int maxx = -0xffffff ;
int main()
{
int n ;
cin >> n ;
for(int i = 1 ; i<=n ; i++ )
cin >>a[i] ;
for(int i = 1 ; i<=n ; i++)
{
if(a[i-1] < a[i])
{
ans++ ;
}
else
{
ans = 1 ;
}
maxx = max(maxx,ans) ;
}
cout<<maxx;
return 0 ;
}