結果

問題 No.1021 Children in Classrooms
ユーザー htensaihtensai
提出日時 2020-04-30 11:26:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 826 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 73,740 KB
実行使用メモリ 71,208 KB
最終ジャッジ日時 2023-08-21 12:52:13
合計ジャッジ時間 14,760 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
56,068 KB
testcase_01 AC 118 ms
56,316 KB
testcase_02 AC 117 ms
56,456 KB
testcase_03 AC 194 ms
58,804 KB
testcase_04 AC 197 ms
58,544 KB
testcase_05 AC 195 ms
58,004 KB
testcase_06 AC 196 ms
58,484 KB
testcase_07 AC 200 ms
58,572 KB
testcase_08 AC 205 ms
58,616 KB
testcase_09 AC 803 ms
70,784 KB
testcase_10 AC 821 ms
70,932 KB
testcase_11 AC 820 ms
70,968 KB
testcase_12 AC 794 ms
70,760 KB
testcase_13 AC 810 ms
71,036 KB
testcase_14 AC 826 ms
71,208 KB
testcase_15 AC 701 ms
69,172 KB
testcase_16 AC 693 ms
69,116 KB
testcase_17 AC 732 ms
69,324 KB
testcase_18 AC 799 ms
70,808 KB
testcase_19 AC 244 ms
59,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayDeque<Integer> deq = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            deq.add(sc.nextInt());
        }
        char[] arr = sc.next().toCharArray();
        for (char c : arr) {
            if (c == 'L') {
                deq.addFirst(deq.pollFirst() + deq.pollFirst());
                deq.addLast(0);
            } else {
                deq.addLast(deq.pollLast() + deq.pollLast());
                deq.addFirst(0);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(deq.pollFirst());
        }
        System.out.println(sb);
    }
}
0