結果

問題 No.1021 Children in Classrooms
ユーザー ntk3264ntk3264
提出日時 2020-04-11 20:14:51
言語 Java19
(openjdk 21)
結果
AC  
実行時間 901 ms / 2,000 ms
コード長 993 bytes
コンパイル時間 2,174 ms
コンパイル使用メモリ 79,512 KB
実行使用メモリ 76,824 KB
最終ジャッジ日時 2023-10-19 12:29:53
合計ジャッジ時間 14,343 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
57,788 KB
testcase_01 AC 136 ms
57,472 KB
testcase_02 AC 141 ms
57,876 KB
testcase_03 AC 218 ms
60,448 KB
testcase_04 AC 218 ms
60,316 KB
testcase_05 AC 209 ms
60,296 KB
testcase_06 AC 219 ms
60,360 KB
testcase_07 AC 225 ms
60,372 KB
testcase_08 AC 224 ms
60,444 KB
testcase_09 AC 866 ms
76,744 KB
testcase_10 AC 844 ms
76,760 KB
testcase_11 AC 889 ms
76,824 KB
testcase_12 AC 901 ms
75,864 KB
testcase_13 AC 845 ms
76,760 KB
testcase_14 AC 861 ms
76,692 KB
testcase_15 AC 730 ms
73,112 KB
testcase_16 AC 722 ms
73,232 KB
testcase_17 AC 749 ms
73,212 KB
testcase_18 AC 842 ms
73,284 KB
testcase_19 AC 239 ms
62,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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