結果

問題 No.938 賢人を探せ
ユーザー tentententen
提出日時 2020-08-26 18:34:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 380 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 4,004 ms
コンパイル使用メモリ 71,580 KB
実行使用メモリ 63,556 KB
最終ジャッジ日時 2023-08-21 03:46:42
合計ジャッジ時間 9,645 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 380 ms
63,556 KB
testcase_01 AC 122 ms
55,848 KB
testcase_02 AC 122 ms
55,716 KB
testcase_03 AC 124 ms
56,072 KB
testcase_04 AC 127 ms
55,492 KB
testcase_05 AC 124 ms
56,168 KB
testcase_06 AC 126 ms
56,200 KB
testcase_07 AC 126 ms
55,520 KB
testcase_08 AC 285 ms
62,588 KB
testcase_09 AC 295 ms
62,836 KB
testcase_10 AC 123 ms
55,556 KB
testcase_11 AC 307 ms
62,772 KB
testcase_12 AC 290 ms
62,796 KB
testcase_13 AC 292 ms
62,708 KB
testcase_14 AC 284 ms
62,524 KB
testcase_15 AC 290 ms
62,984 KB
testcase_16 AC 285 ms
63,000 KB
testcase_17 AC 291 ms
62,592 KB
testcase_18 AC 286 ms
62,680 KB
testcase_19 AC 287 ms
62,708 KB
testcase_20 AC 277 ms
62,708 KB
testcase_21 AC 287 ms
62,696 KB
testcase_22 AC 317 ms
63,088 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