結果

問題 No.1021 Children in Classrooms
ユーザー leaf_1415leaf_1415
提出日時 2020-04-10 21:31:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,422 bytes
コンパイル時間 2,335 ms
コンパイル使用メモリ 74,224 KB
実行使用メモリ 6,796 KB
最終ジャッジ日時 2023-10-13 23:42:15
合計ジャッジ時間 4,820 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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,356 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 WA -
testcase_09 AC 34 ms
6,700 KB
testcase_10 AC 35 ms
6,728 KB
testcase_11 AC 34 ms
6,628 KB
testcase_12 AC 34 ms
6,780 KB
testcase_13 AC 34 ms
6,612 KB
testcase_14 AC 34 ms
6,636 KB
testcase_15 AC 25 ms
6,040 KB
testcase_16 WA -
testcase_17 AC 27 ms
6,156 KB
testcase_18 WA -
testcase_19 AC 4 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, m;
llint a[200005], sum[200005];
string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	cin >> s;
	
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
	
	llint l = 1, r = n, L = 1, R = n;
	for(int i = 0; i < s.size(); i++){
		if(l == r){
			if(s[i] == 'L'){
				if(l > 1) l--, r--;
			}
			else{
				if(r < n) l++, r++;
			}
			continue;
		}
		if(s[i] == 'L'){
			if(l > 1) l--, r--;
			else L++, r--;
		}
		else{
			if(r < n) l++, r++;
			else R--, l++;
		}
	}
	//cout << l << " " << r << endl;
	
	for(int i = 1; i <= n; i++){
		if(i < l || i > r){
			cout << 0 << " ";
			continue;
		}
		if(i == l) cout << sum[L] << " ";
		else if(i == r) cout << sum[n]-sum[R-1] << " ";
		else cout << a[(i-l)+L] << " ";
	}
	cout << endl;
	
	return 0;
}
0