結果

問題 No.938 賢人を探せ
ユーザー tenten
提出日時 2020-08-26 18:34:43
言語 Java
(openjdk 23)
結果
AC  
実行時間 409 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 3,010 ms
コンパイル使用メモリ 75,316 KB
実行使用メモリ 61,792 KB
最終ジャッジ日時 2024-12-14 12:00:42
合計ジャッジ時間 10,404 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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