結果

問題 No.1021 Children in Classrooms
ユーザー merom686merom686
提出日時 2020-04-10 21:46:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 76,248 KB
実行使用メモリ 4,516 KB
最終ジャッジ日時 2023-10-13 23:57:45
合計ジャッジ時間 2,528 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.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;
    for (int j = 0; j < m; j++) {
        if (s[j] == 'L') {
            if (l >= 0 && l + 1 < n) a[l + 1] += a[l], a[l] = 0;
            if (l + 1 < n) l++;
        } else {
            int r = l + n - 1;
            if (r < n && r - 1 >= 0) a[r - 1] += a[r], a[r] = 0;
            if (r - 1 >= 0) l--;
        }
    }

    for (int i = 0; i < n; i++) {
        int k = l + i;
        cout << ((0 <= k && k < n) ? a[k] : 0) << " \n"[i == n - 1];
    }

    return 0;
}
0