結果

問題 No.1021 Children in Classrooms
ユーザー veqccveqcc
提出日時 2020-04-10 21:40:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,111 bytes
コンパイル時間 985 ms
コンパイル使用メモリ 104,480 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-13 23:51:15
合計ジャッジ時間 4,558 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
4,348 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 23 ms
4,436 KB
testcase_19 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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