結果

問題 No.2154 あさかつの参加人数
ユーザー tentententen
提出日時 2022-12-26 09:10:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 746 ms / 2,000 ms
コード長 1,734 bytes
コンパイル時間 2,358 ms
コンパイル使用メモリ 95,512 KB
実行使用メモリ 91,472 KB
最終ジャッジ日時 2024-04-30 19:35:42
合計ジャッジ時間 23,443 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 722 ms
91,008 KB
testcase_01 AC 746 ms
91,472 KB
testcase_02 AC 710 ms
90,748 KB
testcase_03 AC 716 ms
90,868 KB
testcase_04 AC 730 ms
90,504 KB
testcase_05 AC 395 ms
59,144 KB
testcase_06 AC 555 ms
69,168 KB
testcase_07 AC 569 ms
81,552 KB
testcase_08 AC 581 ms
82,720 KB
testcase_09 AC 324 ms
70,092 KB
testcase_10 AC 506 ms
73,640 KB
testcase_11 AC 656 ms
83,620 KB
testcase_12 AC 589 ms
74,108 KB
testcase_13 AC 416 ms
63,456 KB
testcase_14 AC 615 ms
72,140 KB
testcase_15 AC 576 ms
81,400 KB
testcase_16 AC 662 ms
84,432 KB
testcase_17 AC 576 ms
70,812 KB
testcase_18 AC 657 ms
82,532 KB
testcase_19 AC 213 ms
60,008 KB
testcase_20 AC 662 ms
82,020 KB
testcase_21 AC 330 ms
69,672 KB
testcase_22 AC 508 ms
83,688 KB
testcase_23 AC 699 ms
82,704 KB
testcase_24 AC 701 ms
83,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] imos = new int[n];
        for (int i = 0; i < m; i++) {
            int left = sc.nextInt();
            int right = sc.nextInt();
            imos[n - left]++;
            if (right > 1) {
                imos[n - right + 1]--;
            }
        }
        for (int i = 1; i < n; i++) {
            imos[i] += imos[i - 1];
        }
        System.out.println(Utilities.arrayToLineString(imos));
    }
}
class Utilities {
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0