結果

問題 No.1021 Children in Classrooms
ユーザー QCFiumQCFium
提出日時 2020-04-10 21:31:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 172,072 KB
実行使用メモリ 5,232 KB
最終ジャッジ日時 2023-10-13 23:25:33
合計ジャッジ時間 3,780 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 WA -
testcase_09 AC 43 ms
5,080 KB
testcase_10 AC 43 ms
5,232 KB
testcase_11 AC 43 ms
5,164 KB
testcase_12 AC 41 ms
5,068 KB
testcase_13 AC 41 ms
5,188 KB
testcase_14 AC 42 ms
5,160 KB
testcase_15 AC 32 ms
4,744 KB
testcase_16 WA -
testcase_17 AC 35 ms
4,792 KB
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int a[n];
	for (auto &i : a) i = ri();
	std::string s;
	std::cin >> s;
	int left_clear = 0;
	int right_clear = 0;
	std::deque<int> all(a, a + n);
	for (int i = 0; i < m; i++) {
		if (s[i] == 'R') {
			if (right_clear) right_clear--;
			else if (all.size() > 1) all[all.size() - 2] += all.back(), all.pop_back();
			left_clear++;
		} else {
			if (left_clear) left_clear--;
			else if (all.size() > 1) all[1] += all[0], all.pop_front();
			right_clear++;
		}
	}
	for (int i = 0; i < left_clear; i++) all.push_front(0);
	all.resize(n);
	for (int i = 0; i < n; i++) printf("%d ", all[i]);
	puts("");
	return 0;
}
0