結果

問題 No.1390 Get together
ユーザー tentententen
提出日時 2021-02-13 16:36:28
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 675 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 73,484 KB
実行使用メモリ 118,512 KB
最終ジャッジ日時 2023-09-28 01:06:38
合計ジャッジ時間 31,976 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,940 KB
testcase_01 AC 128 ms
55,736 KB
testcase_02 AC 131 ms
55,556 KB
testcase_03 AC 252 ms
59,480 KB
testcase_04 AC 243 ms
59,144 KB
testcase_05 WA -
testcase_06 AC 249 ms
59,184 KB
testcase_07 WA -
testcase_08 AC 239 ms
59,264 KB
testcase_09 AC 270 ms
60,076 KB
testcase_10 AC 129 ms
55,872 KB
testcase_11 AC 131 ms
55,376 KB
testcase_12 AC 134 ms
55,908 KB
testcase_13 WA -
testcase_14 AC 135 ms
55,536 KB
testcase_15 AC 129 ms
56,084 KB
testcase_16 AC 1,213 ms
71,332 KB
testcase_17 AC 1,486 ms
112,628 KB
testcase_18 AC 1,237 ms
79,892 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,611 ms
116,932 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1,643 ms
116,572 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        HashMap<Integer, HashSet<Integer>> counts = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int b = sc.nextInt();
            int c = sc.nextInt();
            if (!counts.containsKey(c)) {
                counts.put(c, new HashSet<>());
            }
            counts.get(c).add(b);
        }
        int ans = 0;
        for (HashSet<Integer> set : counts.values()) {
            ans += set.size() - 1;
        }
        System.out.println(ans);
    }
}
0