結果

問題 No.1021 Children in Classrooms
ユーザー ks2mks2m
提出日時 2020-04-10 21:42:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 382 ms / 2,000 ms
コード長 952 bytes
コンパイル時間 3,941 ms
コンパイル使用メモリ 74,384 KB
実行使用メモリ 72,332 KB
最終ジャッジ日時 2023-10-13 23:53:04
合計ジャッジ時間 8,559 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
51,120 KB
testcase_01 AC 46 ms
51,388 KB
testcase_02 AC 45 ms
51,532 KB
testcase_03 AC 56 ms
53,208 KB
testcase_04 AC 59 ms
52,592 KB
testcase_05 AC 58 ms
53,244 KB
testcase_06 AC 58 ms
52,260 KB
testcase_07 AC 60 ms
52,240 KB
testcase_08 AC 60 ms
53,112 KB
testcase_09 AC 341 ms
70,904 KB
testcase_10 AC 334 ms
71,776 KB
testcase_11 AC 335 ms
71,612 KB
testcase_12 AC 360 ms
71,128 KB
testcase_13 AC 382 ms
71,384 KB
testcase_14 AC 335 ms
71,372 KB
testcase_15 AC 272 ms
64,896 KB
testcase_16 AC 276 ms
65,992 KB
testcase_17 AC 283 ms
63,676 KB
testcase_18 AC 324 ms
72,332 KB
testcase_19 AC 90 ms
54,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[600005];
		for (int i = 0; i < n; i++) {
			a[200001 + i] = Integer.parseInt(sa[i]);
		}
		char[] s = br.readLine().toCharArray();
		br.close();

		int l = 200001;
		int r = 200001 + n - 1;
		for (int i = 0; i < m; i++) {
			if (s[i] == 'L') {
				a[l + 1] += a[l];
				a[l] = 0;
				l++;
				r++;
			} else {
				a[r - 1] += a[r];
				a[r] = 0;
				r--;
				l--;
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = l; i < l + n; i++) {
			sb.append(a[i]).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}
0