• 【洛谷】P1567 统计天数


    P1567 统计天数

    题目背景

    统计天数

    题目描述

    炎热的夏日,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

    说明

    时间限制1s 内存限制128MB



    #include<iostream>
    #include<cstdio>
    
    int n;
    int maxl;
    
    int main()
    {
    	scanf("%d",&n);
    	int cnt=0,pre=0;
            max=1;
            for(int i=1;i<=n;i++)
    	{
    		int a;
    		scanf("%d",&a);
    		if(pre<a)
    		{	
    			cnt++;
    			pre=a; 	
    		} 
    		else
    		{		
    			maxl=std::max(cnt,maxl);
    			cnt=1;	
    		}
    		pre=a; 	
    	}
    	printf("%d",maxl); 
    	return 0;
    }

    水一下

  • 相关阅读:
    Python编程知识
    Ubuntu 20.04.3 LTS + Intel Realsense 400系列
    Kubectl
    在Debian Buster中安装redis-cli
    MySQL中最近执行的查询的信息
    EntityFramework 在脚本中使用in
    CLDR TimeZone Mapper
    Skyspark Axon
    Async Restsharp call
    HTTP 1.1 中的Accept-Language header
  • 原文地址:https://www.cnblogs.com/huibixiaoxing/p/6537760.html
Copyright © 2020-2023  润新知