結果

問題 No.610 区間賞(Section Award)
ユーザー htensaihtensai
提出日時 2020-01-27 09:07:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 895 ms / 2,000 ms
コード長 1,095 bytes
コンパイル時間 2,964 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 73,876 KB
最終ジャッジ日時 2023-10-12 12:50:21
合計ジャッジ時間 29,335 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,904 KB
testcase_01 AC 121 ms
56,168 KB
testcase_02 AC 121 ms
55,708 KB
testcase_03 AC 121 ms
55,692 KB
testcase_04 AC 124 ms
55,916 KB
testcase_05 AC 146 ms
56,052 KB
testcase_06 AC 190 ms
58,500 KB
testcase_07 AC 175 ms
56,120 KB
testcase_08 AC 195 ms
58,564 KB
testcase_09 AC 180 ms
56,176 KB
testcase_10 AC 189 ms
58,624 KB
testcase_11 AC 193 ms
58,828 KB
testcase_12 AC 137 ms
56,020 KB
testcase_13 AC 197 ms
58,408 KB
testcase_14 AC 194 ms
58,808 KB
testcase_15 AC 191 ms
58,436 KB
testcase_16 AC 190 ms
58,012 KB
testcase_17 AC 182 ms
56,100 KB
testcase_18 AC 165 ms
55,808 KB
testcase_19 AC 405 ms
60,836 KB
testcase_20 AC 751 ms
70,760 KB
testcase_21 AC 368 ms
60,884 KB
testcase_22 AC 648 ms
70,308 KB
testcase_23 AC 296 ms
60,164 KB
testcase_24 AC 438 ms
60,740 KB
testcase_25 AC 263 ms
60,292 KB
testcase_26 AC 556 ms
62,748 KB
testcase_27 AC 783 ms
72,656 KB
testcase_28 AC 726 ms
70,968 KB
testcase_29 AC 639 ms
67,248 KB
testcase_30 AC 746 ms
71,480 KB
testcase_31 AC 557 ms
62,624 KB
testcase_32 AC 767 ms
70,748 KB
testcase_33 AC 350 ms
58,404 KB
testcase_34 AC 813 ms
73,312 KB
testcase_35 AC 552 ms
63,288 KB
testcase_36 AC 812 ms
73,336 KB
testcase_37 AC 754 ms
71,440 KB
testcase_38 AC 433 ms
61,260 KB
testcase_39 AC 845 ms
72,008 KB
testcase_40 AC 831 ms
73,272 KB
testcase_41 AC 803 ms
72,524 KB
testcase_42 AC 826 ms
73,240 KB
testcase_43 AC 810 ms
72,244 KB
testcase_44 AC 813 ms
72,296 KB
testcase_45 AC 895 ms
72,256 KB
testcase_46 AC 880 ms
73,876 KB
testcase_47 AC 715 ms
71,032 KB
testcase_48 AC 684 ms
71,348 KB
testcase_49 AC 704 ms
71,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[]  args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayDeque<Integer> befores = new ArrayDeque<>();
        ArrayDeque<Integer> afters = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            befores.add(sc.nextInt());
        }
        for (int i = 0; i < n; i++) {
            afters.add(sc.nextInt());
        }
        HashSet<Integer> loses = new HashSet<>();
        TreeSet<Integer> wins = new TreeSet<>();
        while (afters.size() > 0) {
            int x = afters.poll();
            if (loses.contains(x)) {
                continue;
            }
            while (befores.size() > 0) {
                int y = befores.poll();
                if (x == y) {
                    break;
                }
                loses.add(y);
            }
            wins.add(x);
        }
        StringBuilder sb = new StringBuilder();
        for (int x : wins) {
            sb.append(x).append("\n");
        }
        System.out.print(sb);
    }
}
0