結果
問題 | No.893 お客様を誘導せよ |
ユーザー |
![]() |
提出日時 | 2020-08-30 21:42:10 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 621 ms / 2,000 ms |
コード長 | 849 bytes |
コンパイル時間 | 2,385 ms |
コンパイル使用メモリ | 77,148 KB |
実行使用メモリ | 61,524 KB |
最終ジャッジ日時 | 2024-11-15 15:32:42 |
合計ジャッジ時間 | 7,175 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayDeque<ArrayDeque<Integer>> all = new ArrayDeque<>(); for (int i = 0; i < n; i++) { int p = sc.nextInt(); if (p == 0) { continue; } ArrayDeque<Integer> tmp = new ArrayDeque<>(); for (int j = 0; j < p; j++) { tmp.add(sc.nextInt()); } all.add(tmp); } StringBuilder sb = new StringBuilder(); while (all.size() > 0) { ArrayDeque<Integer> tmp = all.poll(); if (sb.length() > 0) { sb.append(" "); } sb.append(tmp.poll()); if (tmp.size() > 0) { all.add(tmp); } } System.out.println(sb); } }