結果

問題 No.1021 Children in Classrooms
ユーザー mencottonmencotton
提出日時 2020-11-02 16:38:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 599 ms
コンパイル使用メモリ 72,036 KB
実行使用メモリ 4,436 KB
最終ジャッジ日時 2023-09-29 11:59:51
合計ジャッジ時間 4,024 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    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 left = 0, right = n - 1, now = 0;
    for (int i = 0; i < m; i++) {
        if (s[i] == 'L')now++;
        else now--;

        now = min(now, n - 1), now = max(now, -(n - 1));

        left = max(left, now), right = min(right, now + n - 1);
    }

    for (int i = 0; i < left; i++) a[left] += a[i], a[i] = 0;
    for (int i = n - 1; i > right; i--) a[right] += a[i], a[i] = 0;

    for (int i = 0; i < n; i++) {
        if (i > 0)cout << " ";
        if (0 <= i + now && i + now < n) cout << a[i + now];
        else cout << 0;
    }
    cout << endl;
    return 0;
}
0