結果

問題 No.1021 Children in Classrooms
コンテスト
ユーザー ntk3264
提出日時 2020-04-11 20:14:51
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 551 ms / 2,000 ms
コード長 993 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,311 ms
コンパイル使用メモリ 83,304 KB
実行使用メモリ 63,348 KB
最終ジャッジ日時 2026-04-07 17:40:35
合計ジャッジ時間 11,514 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[n+m*2];
        for (int i=m; i<n+m; i++) arr[i] = sc.nextInt();
//        List<Integer> list = new ArrayList<>();
//        for (int i=0; i<n; i++) list.add(sc.nextInt());
        char[] order = sc.next().toCharArray();

        int idxS = m;

        for (int i=0; i<m; i++) {
            if (order[i]=='L') {
                arr[idxS+1] += arr[idxS];
                arr[idxS] = 0;
                idxS++;
            } else {
                arr[idxS+n-2] += arr[idxS+n-1];
                arr[idxS+n-1] = 0;
                idxS--;
            }
        }

        StringBuilder sb = new StringBuilder();

        for (int i=idxS; i<idxS+n; i++) sb.append(arr[i]+" ");

        System.out.println(sb.toString());
    }
}
0