結果

問題 No.1021 Children in Classrooms
ユーザー mencottonmencotton
提出日時 2020-11-02 16:48:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 77,896 KB
実行使用メモリ 4,552 KB
最終ジャッジ日時 2023-09-29 12:00:26
合計ジャッジ時間 2,738 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    deque<int> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    string s;
    cin >> s;

    for (int i = 0; i < m; i++) {
        if (s[i] == 'L') {
            int x = a.front();
            a.pop_front();
            a.front() += x;
            a.push_back(0);
        } else {
            int x = a.back();
            a.pop_back();
            a.back() += x;
            a.push_front(0);
        }
    }

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