• Java实现 洛谷 P1567 统计天数


    在这里插入图片描述

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.StringTokenizer;
    
    public class Main {
        private static CustomizedReader cin;
    
        public static void main(String args[]) throws Exception {
            cin = new CustomizedReader(System.in);
            int n = cin.nextInt();
            if(n<=0 || n>Math.pow(10, 7)) {
                return;
            }
            int historyRecord = 0;
            int newRecord = 0;
            int startTemprature = -1;
            int MAX = (int) Math.pow(10, 9);
            for (int i = 0; i < n; i++) {
                int t = cin.nextInt();
                if(t>=0&&t<=MAX) {
                    if(t > startTemprature) {
                        newRecord++;
                        startTemprature = t;
                    }else {
                        if(newRecord > historyRecord) {
                            historyRecord = newRecord;
                        }
                        newRecord = 1;
                        startTemprature = t;
                    }
                }
            }
            if(newRecord > historyRecord) {
                historyRecord = newRecord;
            }
            System.out.println(historyRecord);
        }
    }
    
    class CustomizedReader {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer;
        
        CustomizedReader(InputStream source){
            reader = new BufferedReader(new InputStreamReader(source) );
            tokenizer = new StringTokenizer("");
        }
        
        public String next() {
            while ( ! tokenizer.hasMoreTokens() ) {
                //TODO add check for eof if necessary
                try {
                    tokenizer = new StringTokenizer(reader.readLine() );
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
            
        }
        
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public double nextDouble() {
            return Double.parseDouble(next());
        }
        
        public double nextLong() {
            return Long.parseLong(next());
        }
        
        public double nextFloat() {
            return Float.parseFloat(next());
        }
        
    }    
    
    
  • 相关阅读:
    MyBatisPartA
    概念:漏洞扫描技术
    概念:防火墙技术
    概念:认证技术与访问控制
    概念:为什么要引进密钥管理技术
    概念:数字签名、传统签名和认证
    概念:简述对称密码算法和公钥密码算法的区别
    概念:单向散列函数部分知识点
    Redis单线程QPS效率高的原因,以及redis6.0升级后的变化
    Mydql数据库缓存池Buffer Pool 冷热数据分离
  • 原文地址:https://www.cnblogs.com/a1439775520/p/13076220.html
Copyright © 2020-2023  润新知