結果

問題 No.1021 Children in Classrooms
ユーザー CELICACELICA
提出日時 2020-09-02 21:11:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 729 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 171,332 KB
実行使用メモリ 7,076 KB
最終ジャッジ日時 2023-08-14 02:52:14
合計ジャッジ時間 4,963 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 32 ms
7,076 KB
testcase_10 AC 33 ms
7,060 KB
testcase_11 AC 33 ms
6,960 KB
testcase_12 AC 32 ms
6,936 KB
testcase_13 AC 32 ms
7,008 KB
testcase_14 AC 32 ms
6,960 KB
testcase_15 AC 22 ms
4,652 KB
testcase_16 AC 23 ms
4,816 KB
testcase_17 AC 24 ms
4,824 KB
testcase_18 AC 30 ms
5,084 KB
testcase_19 AC 4 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ul = unsigned long;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, m;
	cin >> n >> m;

	deque<int> a;
	for (int i = 0; i < n; ++i)
	{
		int aa;
		cin >> aa;
		a.push_back(aa);
	}

	string s;
	cin >> s;
	for (const auto& is : s)
	{
		if (is == 'L')
		{
			int aa = a.front();
			a.pop_front();
			a.front() += aa;
			a.push_back(0);
		}
		else
		{
			int aa = a.back();
			a.pop_back();
			a.back() += aa;
			a.push_front(0);
		}
	}

	stringstream ss;
	for (int i = 0; i < n; ++i)
	{
		ss << a.front() << " ";
		a.pop_front();
	}

	string res = ss.str();
	res = res.substr(0, res.size() - 1);

	cout << res << "\n";

	return 0;
}
0