結果

問題 No.1021 Children in Classrooms
ユーザー misora192misora192
提出日時 2020-04-12 08:49:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 4,185 ms
コンパイル使用メモリ 173,156 KB
実行使用メモリ 5,500 KB
最終ジャッジ日時 2023-10-22 00:40:24
合計ジャッジ時間 4,673 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 30 ms
5,408 KB
testcase_10 AC 32 ms
5,412 KB
testcase_11 AC 32 ms
5,248 KB
testcase_12 AC 29 ms
5,408 KB
testcase_13 AC 29 ms
5,408 KB
testcase_14 AC 30 ms
5,408 KB
testcase_15 AC 22 ms
5,016 KB
testcase_16 AC 23 ms
4,916 KB
testcase_17 AC 23 ms
5,088 KB
testcase_18 AC 31 ms
5,500 KB
testcase_19 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;

	deque<ll> a;
	rep(i, n){
		ll x;
		cin >> x;

		a.push_back(x);
	} 

	string s;
	cin >> s;

	rep(i, m){
		if(s[i] == 'L'){
			ll x = a.front();
			a.pop_front();
			x += a.front();
			a.pop_front();
			a.push_front(x);
			a.push_back(0);
		}else{
			ll x = a.back();
			a.pop_back();
			x += a.back();
			a.pop_back();
			a.push_back(x);
			a.push_front(0);
		}
	}
	
	int cnt = 0;
	for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
		cnt++;
		if(cnt < n) cout << " ";
	}
	cout << "\n";
}
0