美文网首页
CCF201809-2:买菜(JAVA版)

CCF201809-2:买菜(JAVA版)

作者: 巨鹿lx | 来源:发表于2020-03-18 23:33 被阅读0次
    import java.util.Scanner;
    
    public class Main{
        static int N = 1000010;
        static int cnt[] = new int[N];
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            int res = 0;
            for(int i = 1; i <= n*2 ; i++) {
                int a = scanner.nextInt();
                int b = scanner.nextInt();
                for(int j = a; j < b ; j ++) {
                    cnt[j]++;
                    if(cnt[j]==2) res++;
                }
            }
            System.out.println(res);
        }
    }
    

    相关文章

      网友评论

          本文标题:CCF201809-2:买菜(JAVA版)

          本文链接:https://www.haomeiwen.com/subject/smbhyhtx.html