結果
| 問題 |
No.610 区間賞(Section Award)
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-11-12 14:58:27 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 547 ms / 2,000 ms |
| コード長 | 1,765 bytes |
| コンパイル時間 | 2,299 ms |
| コンパイル使用メモリ | 78,788 KB |
| 実行使用メモリ | 66,932 KB |
| 最終ジャッジ日時 | 2024-11-25 01:35:12 |
| 合計ジャッジ時間 | 15,333 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
int n = sc.nextInt();
ArrayDeque<Integer> starts = new ArrayDeque<>();
for (int i = 0; i < n; i++) {
starts.add(sc.nextInt());
}
HashSet<Integer> used = new HashSet<>();
ArrayList<Integer> ans = new ArrayList<>();
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
if (used.contains(x)) {
continue;
}
ans.add(x);
while (true) {
int y = starts.poll();
used.add(y);
if (x == y) {
break;
}
}
}
Collections.sort(ans);
StringBuilder sb = new StringBuilder();
for (int x : ans) {
sb.append(x).append("\n");
}
System.out.print(sb);
}
}
class Scanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
public Scanner() throws Exception {
}
public int nextInt() throws Exception {
return Integer.parseInt(next());
}
public long nextLong() throws Exception {
return Long.parseLong(next());
}
public double nextDouble() throws Exception {
return Double.parseDouble(next());
}
public String nextLine() throws Exception {
return br.readLine();
}
public String next() throws Exception {
if (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
}
tenten