zoukankan      html  css  js  c++  java
  • 弹幕

    弹幕

    import java.util.*;
    
    public class Solution {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int N = Integer.parseInt(sc.nextLine());
            List<List<Integer>> list = new ArrayList<>();
            int big = 0;
            for (int i = 0;i<N;i++){
                String temp = sc.nextLine();
                String[] tempString = temp.split(" ");
                int first = Integer.parseInt(tempString[0]);
                int second = Integer.parseInt(tempString[1]);
                List<Integer> tempList = new ArrayList<>();
                tempList.add(first);
                tempList.add(second);
                if (second>big)big=second;
                list.add(tempList);
            }
            Map<Integer,Integer> map = new HashMap<>();
            for (List<Integer> tempList:list){
                int first = tempList.get(0);
                int second = tempList.get(1);
                for (int i = first;i<second;i++){
                    if(map.containsKey(i)){
                        map.put(i,map.get(i)+1);
                    }else {
                        map.put(i,1);
                    }
                }
            }
            int max = 0;
            for(int val:map.values()){
                if (val>max)max=val;
            }
            int maxKey = 0;
            int minKey = 100;
            for (int val:map.keySet()){
                if (val>maxKey)maxKey=val;
                if (val<minKey)minKey=val;
            }
            for (int i=minKey;i<=maxKey;i++){
                if (map.get(i)==max){
                    System.out.println(i+" "+(i+1));
                }
            }
    
        }
    
    }

    弹幕

  • 相关阅读:
    bzoj 1040: [ZJOI2008]骑士
    CF Playrix Codescapes Cup Problems Analysis
    C++ 指针[转+原创]
    高斯消元
    NOIP模拟
    线段树合并
    After ZJOI2017 day2
    ZJOI 2017 day2 4.27
    ZJOI 2017 二试 day1 4.26
    ZJOI 2017 二试 day0
  • 原文地址:https://www.cnblogs.com/LoganChen/p/13721412.html
Copyright © 2011-2022 走看看