結果
問題 | No.610 区間賞(Section Award) |
ユーザー |
![]() |
提出日時 | 2020-12-25 09:33:19 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,243 ms / 2,000 ms |
コード長 | 854 bytes |
コンパイル時間 | 2,430 ms |
コンパイル使用メモリ | 86,396 KB |
実行使用メモリ | 73,048 KB |
最終ジャッジ日時 | 2024-09-22 02:12:30 |
合計ジャッジ時間 | 32,278 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
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);}}