結果

問題 No.1026 OGAWA's New Keyboard
ユーザー htensaihtensai
提出日時 2020-04-30 10:07:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 830 ms / 1,000 ms
コード長 603 bytes
コンパイル時間 4,010 ms
コンパイル使用メモリ 77,852 KB
実行使用メモリ 65,208 KB
最終ジャッジ日時 2023-10-14 10:08:37
合計ジャッジ時間 10,763 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,620 KB
testcase_01 AC 126 ms
55,736 KB
testcase_02 AC 128 ms
55,564 KB
testcase_03 AC 125 ms
55,908 KB
testcase_04 AC 830 ms
65,208 KB
testcase_05 AC 234 ms
60,164 KB
testcase_06 AC 260 ms
60,156 KB
testcase_07 AC 662 ms
64,636 KB
testcase_08 AC 221 ms
59,808 KB
testcase_09 AC 133 ms
55,624 KB
testcase_10 AC 191 ms
59,072 KB
testcase_11 AC 186 ms
56,884 KB
testcase_12 AC 149 ms
55,748 KB
testcase_13 AC 127 ms
55,568 KB
testcase_14 AC 139 ms
55,948 KB
testcase_15 AC 150 ms
55,484 KB
testcase_16 AC 191 ms
57,092 KB
testcase_17 AC 440 ms
60,560 KB
testcase_18 AC 193 ms
59,464 KB
testcase_19 AC 422 ms
61,072 KB
testcase_20 AC 139 ms
55,636 KB
testcase_21 AC 128 ms
55,504 KB
testcase_22 AC 185 ms
57,220 KB
testcase_23 AC 195 ms
57,456 KB
testcase_24 AC 590 ms
64,976 KB
testcase_25 AC 189 ms
58,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayDeque<Character> deq = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            if (sc.nextInt() == 0) {
                deq.addLast(sc.next().charAt(0));
            } else {
                deq.addFirst(sc.next().charAt(0));
            }
        }
        StringBuilder sb = new StringBuilder();
        while (deq.size() > 0) {
            sb.append(deq.poll());
        }
        System.out.println(sb);
    }
}
0