結果
問題 | No.610 区間賞(Section Award) |
ユーザー | tenten |
提出日時 | 2021-11-12 14:58:27 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 559 ms / 2,000 ms |
コード長 | 1,765 bytes |
コンパイル時間 | 2,362 ms |
コンパイル使用メモリ | 78,960 KB |
実行使用メモリ | 57,040 KB |
最終ジャッジ日時 | 2024-05-03 21:09:39 |
合計ジャッジ時間 | 14,631 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
36,988 KB |
testcase_01 | AC | 42 ms
36,904 KB |
testcase_02 | AC | 45 ms
37,032 KB |
testcase_03 | AC | 46 ms
36,948 KB |
testcase_04 | AC | 46 ms
36,804 KB |
testcase_05 | AC | 48 ms
36,888 KB |
testcase_06 | AC | 57 ms
37,816 KB |
testcase_07 | AC | 50 ms
36,984 KB |
testcase_08 | AC | 69 ms
38,180 KB |
testcase_09 | AC | 51 ms
36,888 KB |
testcase_10 | AC | 72 ms
37,712 KB |
testcase_11 | AC | 65 ms
37,884 KB |
testcase_12 | AC | 45 ms
36,968 KB |
testcase_13 | AC | 69 ms
37,896 KB |
testcase_14 | AC | 66 ms
37,816 KB |
testcase_15 | AC | 55 ms
36,824 KB |
testcase_16 | AC | 62 ms
37,604 KB |
testcase_17 | AC | 55 ms
37,148 KB |
testcase_18 | AC | 50 ms
36,644 KB |
testcase_19 | AC | 149 ms
44,816 KB |
testcase_20 | AC | 333 ms
53,496 KB |
testcase_21 | AC | 136 ms
42,396 KB |
testcase_22 | AC | 272 ms
50,568 KB |
testcase_23 | AC | 122 ms
41,056 KB |
testcase_24 | AC | 179 ms
44,272 KB |
testcase_25 | AC | 110 ms
39,980 KB |
testcase_26 | AC | 243 ms
47,996 KB |
testcase_27 | AC | 338 ms
53,452 KB |
testcase_28 | AC | 313 ms
52,108 KB |
testcase_29 | AC | 282 ms
49,652 KB |
testcase_30 | AC | 329 ms
52,420 KB |
testcase_31 | AC | 222 ms
47,924 KB |
testcase_32 | AC | 331 ms
53,536 KB |
testcase_33 | AC | 132 ms
42,488 KB |
testcase_34 | AC | 347 ms
54,544 KB |
testcase_35 | AC | 240 ms
48,280 KB |
testcase_36 | AC | 329 ms
53,720 KB |
testcase_37 | AC | 306 ms
52,188 KB |
testcase_38 | AC | 163 ms
44,760 KB |
testcase_39 | AC | 353 ms
54,840 KB |
testcase_40 | AC | 331 ms
54,776 KB |
testcase_41 | AC | 358 ms
54,384 KB |
testcase_42 | AC | 362 ms
54,976 KB |
testcase_43 | AC | 361 ms
54,816 KB |
testcase_44 | AC | 472 ms
55,648 KB |
testcase_45 | AC | 507 ms
56,488 KB |
testcase_46 | AC | 559 ms
57,040 KB |
testcase_47 | AC | 283 ms
52,324 KB |
testcase_48 | AC | 293 ms
51,432 KB |
testcase_49 | AC | 322 ms
52,204 KB |
ソースコード
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(); } }