結果

問題 No.1021 Children in Classrooms
ユーザー CELICA
提出日時 2020-09-02 21:11:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 729 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 173,704 KB
実行使用メモリ 7,268 KB
最終ジャッジ日時 2024-11-21 20:49:45
合計ジャッジ時間 3,795 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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