結果
問題 | No.610 区間賞(Section Award) |
ユーザー |
![]() |
提出日時 | 2020-01-27 09:07:25 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,166 ms / 2,000 ms |
コード長 | 1,095 bytes |
コンパイル時間 | 2,880 ms |
コンパイル使用メモリ | 80,360 KB |
実行使用メモリ | 78,924 KB |
最終ジャッジ日時 | 2024-09-14 11:50:07 |
合計ジャッジ時間 | 34,453 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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(); 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); } }