結果

問題 No.1021 Children in Classrooms
ユーザー Y17Y17
提出日時 2020-04-10 22:59:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,121 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 171,352 KB
実行使用メモリ 8,424 KB
最終ジャッジ日時 2023-10-14 04:03:10
合計ジャッジ時間 4,488 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 3 ms
4,352 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 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 75 ms
8,192 KB
testcase_10 AC 75 ms
8,244 KB
testcase_11 AC 75 ms
8,152 KB
testcase_12 AC 74 ms
8,272 KB
testcase_13 AC 73 ms
8,240 KB
testcase_14 AC 74 ms
8,268 KB
testcase_15 AC 56 ms
6,900 KB
testcase_16 AC 57 ms
6,948 KB
testcase_17 AC 59 ms
7,248 KB
testcase_18 AC 79 ms
8,424 KB
testcase_19 AC 7 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n, m;
	cin >> n >> m;
	int a[200020];
	deque<int> que;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		que.push_back(a[i]);
	}

	string s;
	cin >> s;

	int l = 0, r = n-1;

	for(int i = 0;i < m;i++){
		if(s[i] == 'L'){
			l--; r--;
			if(l < 0){
				if(r < 0){
					r = 0;
				}else{
					int tmp = que.front();
					que.pop_front();
					tmp += que.front();
					que.pop_front();
					que.push_front(tmp);
				}
				l = 0;
			}
		}else{
			l++; r++;
			if(r >= n){
				if(l >= n){
					l = n-1;
				}else{
					int tmp = que.back();
					que.pop_back();
					tmp += que.back();
					que.pop_back();
					que.push_back(tmp);
				}
				r = n-1;
			}
		}
	}

	vector<int> ans(n, 0);

	for(int i = l;i <= r;i++){
		ans[i] = que[i-l];
	}

	for(int i = 0;i < n;i++){
		cout << ans[i];
		if(i < n-1){
			cout << " "; 
		}else{
			cout << endl;
		}
	}

	return 0;
}
0