結果

問題 No.938 賢人を探せ
ユーザー tentententen
提出日時 2020-08-26 18:34:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 2,641 ms
コンパイル使用メモリ 74,876 KB
実行使用メモリ 61,504 KB
最終ジャッジ日時 2024-05-08 09:17:15
合計ジャッジ時間 9,533 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 393 ms
61,460 KB
testcase_01 AC 130 ms
54,180 KB
testcase_02 AC 130 ms
54,056 KB
testcase_03 AC 133 ms
54,204 KB
testcase_04 AC 122 ms
52,976 KB
testcase_05 AC 132 ms
53,908 KB
testcase_06 AC 129 ms
53,888 KB
testcase_07 AC 129 ms
53,856 KB
testcase_08 AC 294 ms
60,856 KB
testcase_09 AC 301 ms
61,316 KB
testcase_10 AC 129 ms
54,212 KB
testcase_11 AC 323 ms
61,200 KB
testcase_12 AC 295 ms
61,076 KB
testcase_13 AC 314 ms
61,164 KB
testcase_14 AC 306 ms
60,932 KB
testcase_15 AC 306 ms
61,324 KB
testcase_16 AC 288 ms
61,504 KB
testcase_17 AC 296 ms
61,284 KB
testcase_18 AC 307 ms
61,020 KB
testcase_19 AC 308 ms
61,068 KB
testcase_20 AC 327 ms
61,376 KB
testcase_21 AC 319 ms
61,228 KB
testcase_22 AC 330 ms
61,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<String> bads = new HashSet<>();
        String[] names = new String[n];
        for (int i = 0; i < n; i++) {
            bads.add(sc.next());
            names[i] = sc.next();
        }
        HashSet<String> used = new HashSet<>();
        StringBuilder sb = new StringBuilder();
        for (String x : names) {
            if (!bads.contains(x) && !used.contains(x)) {
                sb.append(x).append("\n");
                used.add(x);
            }
        }
        System.out.print(sb);
    }
}
0