結果

問題 No.1021 Children in Classrooms
ユーザー tentententen
提出日時 2020-08-21 09:48:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 811 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 2,458 ms
コンパイル使用メモリ 86,628 KB
実行使用メモリ 64,324 KB
最終ジャッジ日時 2024-04-22 05:09:09
合計ジャッジ時間 14,113 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
40,268 KB
testcase_01 AC 110 ms
40,264 KB
testcase_02 AC 117 ms
41,160 KB
testcase_03 AC 184 ms
42,680 KB
testcase_04 AC 191 ms
43,376 KB
testcase_05 AC 184 ms
43,196 KB
testcase_06 AC 192 ms
43,152 KB
testcase_07 AC 184 ms
43,572 KB
testcase_08 AC 185 ms
43,488 KB
testcase_09 AC 802 ms
64,104 KB
testcase_10 AC 791 ms
63,792 KB
testcase_11 AC 764 ms
64,216 KB
testcase_12 AC 730 ms
64,112 KB
testcase_13 AC 811 ms
63,880 KB
testcase_14 AC 804 ms
64,324 KB
testcase_15 AC 694 ms
58,036 KB
testcase_16 AC 741 ms
57,264 KB
testcase_17 AC 752 ms
58,156 KB
testcase_18 AC 747 ms
63,508 KB
testcase_19 AC 234 ms
45,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	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);
		    }
		}
		boolean isFirst = true;
		StringBuilder sb = new StringBuilder();
		for (int x : deq) {
		    if (isFirst) {
		        isFirst = false;
		    } else {
		        sb.append(" ");
		    }
		    sb.append(x);
		}
		System.out.println(sb);
   }
}

0