#include const long long INF = 1LL << 60; const long long MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define rrep(i, n) for (ll i = (n - 1); i >= 0; --i) #define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c))) #define ALL(obj) (obj).begin(), (obj).end() #define RALL(obj) (obj).rbegin(), (obj).rend() #define MAX max #define MIN min #define pb push_back #define to_s to_string #define len(v) (ll)v.size() #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) #define print(x) cout << (x) << '\n' #define drop(x) cout << (x) << '\n', exit(0) #define debug(x) cout << #x << ": " << (x) << '\n' using namespace std; using ll = long long; typedef pair P; typedef vector vec; typedef vector> vec2; typedef vector>> vec3; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N >> M; vec A(N); rep(i, N) cin >> A[i]; string S; cin >> S; vec state(M + 1); rep1(i, M) state[i] += state[i - 1] + (S[i - 1] == 'L' ? -1 : 1); ll f_state = state.back(); vec ans(N); sort(ALL(state)); rep(i, N){ ll l = 0, r = 0; if(state[0] + i < 0) l = abs(state[0] + i); if(state.back() + i >= N) r = abs(state.back() + i - N + 1); ll now = i + f_state + l - r; ans[now] += A[i]; } cout << ans[0]; rep1(i, N - 1) cout << " " << ans[i]; print(""); return 0; }