結果

問題 No.1021 Children in Classrooms
ユーザー veqcc
提出日時 2020-04-10 21:40:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,111 bytes
コンパイル時間 976 ms
コンパイル使用メモリ 105,572 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 19:43:48
合計ジャッジ時間 4,617 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 RE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;

    vector <int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    string s;
    cin >> s;

    int l = 0, r = n - 1;
    for (int i = 0; i < m; i++) {
        if (s[i] == 'L') {
            if (l < n - 1) {
                a[l + 1] += a[l];
                a[l] = 0;
                l++; r++;
            }
        } else {
            if (r > 0) {
                a[r - 1] += a[r];
                a[r] = 0;
                r--; l--;
            }
        }
    }

    for (int i = l; i <= r; i++) {
        if (i >= 0 && i < n) {
            cout << a[i] << ' ';
        } else {
            cout << '0' << ' ';
        }
    }

    cout << endl;
    return 0;
}
0