結果

問題 No.610 区間賞(Section Award)
ユーザー tentententen
提出日時 2020-12-25 09:33:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 991 ms / 2,000 ms
コード長 854 bytes
コンパイル時間 3,844 ms
コンパイル使用メモリ 77,132 KB
実行使用メモリ 86,876 KB
最終ジャッジ日時 2023-10-22 00:50:20
合計ジャッジ時間 27,765 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
57,592 KB
testcase_01 AC 117 ms
57,524 KB
testcase_02 AC 127 ms
57,452 KB
testcase_03 AC 115 ms
57,196 KB
testcase_04 AC 115 ms
57,592 KB
testcase_05 AC 155 ms
57,744 KB
testcase_06 AC 175 ms
60,148 KB
testcase_07 AC 163 ms
57,668 KB
testcase_08 AC 181 ms
59,964 KB
testcase_09 AC 163 ms
57,992 KB
testcase_10 AC 183 ms
59,740 KB
testcase_11 AC 179 ms
59,872 KB
testcase_12 AC 128 ms
57,616 KB
testcase_13 AC 175 ms
60,140 KB
testcase_14 AC 183 ms
59,816 KB
testcase_15 AC 165 ms
59,852 KB
testcase_16 AC 174 ms
57,748 KB
testcase_17 AC 172 ms
57,680 KB
testcase_18 AC 162 ms
57,732 KB
testcase_19 AC 367 ms
61,892 KB
testcase_20 AC 672 ms
77,616 KB
testcase_21 AC 345 ms
62,356 KB
testcase_22 AC 591 ms
70,528 KB
testcase_23 AC 270 ms
61,192 KB
testcase_24 AC 382 ms
63,712 KB
testcase_25 AC 256 ms
61,732 KB
testcase_26 AC 480 ms
64,488 KB
testcase_27 AC 672 ms
77,476 KB
testcase_28 AC 645 ms
72,208 KB
testcase_29 AC 550 ms
69,672 KB
testcase_30 AC 613 ms
72,336 KB
testcase_31 AC 465 ms
63,788 KB
testcase_32 AC 658 ms
73,900 KB
testcase_33 AC 325 ms
62,408 KB
testcase_34 AC 692 ms
77,496 KB
testcase_35 AC 481 ms
64,116 KB
testcase_36 AC 640 ms
75,412 KB
testcase_37 AC 595 ms
71,300 KB
testcase_38 AC 354 ms
61,164 KB
testcase_39 AC 702 ms
78,204 KB
testcase_40 AC 696 ms
77,760 KB
testcase_41 AC 690 ms
77,400 KB
testcase_42 AC 685 ms
77,928 KB
testcase_43 AC 709 ms
77,632 KB
testcase_44 AC 816 ms
81,156 KB
testcase_45 AC 984 ms
86,776 KB
testcase_46 AC 991 ms
86,876 KB
testcase_47 AC 620 ms
72,820 KB
testcase_48 AC 608 ms
71,104 KB
testcase_49 AC 621 ms
72,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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