結果

問題 No.945 YKC饅頭
ユーザー tentententen
提出日時 2021-11-19 16:02:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 959 ms / 2,000 ms
コード長 1,690 bytes
コンパイル時間 5,216 ms
コンパイル使用メモリ 76,540 KB
実行使用メモリ 78,264 KB
最終ジャッジ日時 2023-08-29 23:46:50
合計ジャッジ時間 38,869 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
52,852 KB
testcase_01 AC 92 ms
53,756 KB
testcase_02 AC 106 ms
52,996 KB
testcase_03 AC 127 ms
53,228 KB
testcase_04 AC 106 ms
51,000 KB
testcase_05 AC 112 ms
52,796 KB
testcase_06 AC 121 ms
54,072 KB
testcase_07 AC 117 ms
53,516 KB
testcase_08 AC 106 ms
53,208 KB
testcase_09 AC 111 ms
53,432 KB
testcase_10 AC 116 ms
53,892 KB
testcase_11 AC 111 ms
53,424 KB
testcase_12 AC 117 ms
53,024 KB
testcase_13 AC 124 ms
54,120 KB
testcase_14 AC 122 ms
53,464 KB
testcase_15 AC 115 ms
53,216 KB
testcase_16 AC 105 ms
53,828 KB
testcase_17 AC 117 ms
52,932 KB
testcase_18 AC 121 ms
53,528 KB
testcase_19 AC 107 ms
53,680 KB
testcase_20 AC 98 ms
52,624 KB
testcase_21 AC 100 ms
52,676 KB
testcase_22 AC 133 ms
53,756 KB
testcase_23 AC 131 ms
53,268 KB
testcase_24 AC 125 ms
53,120 KB
testcase_25 AC 133 ms
53,552 KB
testcase_26 AC 129 ms
53,260 KB
testcase_27 AC 102 ms
53,304 KB
testcase_28 AC 101 ms
52,872 KB
testcase_29 AC 86 ms
53,328 KB
testcase_30 AC 87 ms
53,108 KB
testcase_31 AC 288 ms
57,140 KB
testcase_32 AC 336 ms
61,568 KB
testcase_33 AC 448 ms
64,944 KB
testcase_34 AC 476 ms
61,856 KB
testcase_35 AC 620 ms
74,600 KB
testcase_36 AC 455 ms
57,964 KB
testcase_37 AC 450 ms
59,832 KB
testcase_38 AC 453 ms
59,616 KB
testcase_39 AC 362 ms
61,220 KB
testcase_40 AC 385 ms
65,144 KB
testcase_41 AC 310 ms
59,752 KB
testcase_42 AC 577 ms
62,660 KB
testcase_43 AC 421 ms
60,632 KB
testcase_44 AC 582 ms
66,776 KB
testcase_45 AC 959 ms
78,264 KB
testcase_46 AC 253 ms
62,068 KB
testcase_47 AC 790 ms
64,064 KB
testcase_48 AC 287 ms
57,356 KB
testcase_49 AC 452 ms
60,880 KB
testcase_50 AC 600 ms
62,780 KB
testcase_51 AC 730 ms
74,508 KB
testcase_52 AC 661 ms
67,164 KB
testcase_53 AC 614 ms
67,424 KB
testcase_54 AC 679 ms
66,612 KB
testcase_55 AC 720 ms
73,972 KB
testcase_56 AC 285 ms
64,260 KB
testcase_57 AC 283 ms
65,032 KB
testcase_58 AC 773 ms
73,992 KB
testcase_59 AC 822 ms
74,280 KB
testcase_60 AC 626 ms
73,912 KB
testcase_61 AC 803 ms
74,100 KB
testcase_62 AC 729 ms
73,716 KB
testcase_63 AC 280 ms
67,288 KB
testcase_64 AC 641 ms
74,312 KB
testcase_65 AC 593 ms
73,656 KB
testcase_66 AC 584 ms
73,972 KB
testcase_67 AC 771 ms
73,892 KB
testcase_68 AC 649 ms
73,988 KB
testcase_69 AC 446 ms
70,132 KB
testcase_70 AC 468 ms
72,896 KB
testcase_71 AC 496 ms
73,044 KB
testcase_72 AC 677 ms
74,080 KB
testcase_73 AC 847 ms
74,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        TreeSet<Integer> remain = new TreeSet<>();
        for (int i = 1; i <= n; i++) {
            remain.add(i);
        }
        int y = 0;
        int k = 0;
        int c = 0;
        for (int i = 0; i < m; i++) {
            Integer key = sc.nextInt() - 1;
            int end = sc.nextInt();
            char x = sc.next().charAt(0);
            while ((key = remain.higher(key)) != null) {
                if (key > end) {
                    break;
                }
                if (x == 'Y') {
                    y++;
                } else if (x == 'K') {
                    k++;
                } else {
                    c++;
                }
                remain.remove(key);
            }
        }
        System.out.println(y + " " + k + " " + c);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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 String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0