結果

問題 No.1021 Children in Classrooms
ユーザー QCFiumQCFium
提出日時 2020-04-10 21:33:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 171,504 KB
実行使用メモリ 5,204 KB
最終ジャッジ日時 2023-10-13 23:28:48
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 44 ms
5,140 KB
testcase_10 AC 44 ms
5,204 KB
testcase_11 AC 43 ms
5,136 KB
testcase_12 AC 43 ms
5,092 KB
testcase_13 AC 43 ms
5,096 KB
testcase_14 AC 43 ms
5,128 KB
testcase_15 AC 34 ms
4,812 KB
testcase_16 AC 33 ms
4,824 KB
testcase_17 AC 35 ms
4,872 KB
testcase_18 AC 43 ms
5,092 KB
testcase_19 AC 7 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

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();
			if (left_clear + 1 < n) left_clear++;
		} else {
			if (left_clear) left_clear--;
			else if (all.size() > 1) all[1] += all[0], all.pop_front();
			if (right_clear + 1 < n) 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