結果

問題 No.1021 Children in Classrooms
ユーザー mikianaaamikianaaa
提出日時 2020-08-29 11:46:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,002 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 169,088 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 16:16:31
合計ジャッジ時間 4,218 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 38 ms
6,944 KB
testcase_10 AC 38 ms
5,376 KB
testcase_11 AC 37 ms
5,376 KB
testcase_12 AC 36 ms
5,376 KB
testcase_13 AC 37 ms
5,376 KB
testcase_14 AC 37 ms
5,376 KB
testcase_15 AC 29 ms
5,376 KB
testcase_16 AC 28 ms
5,376 KB
testcase_17 AC 29 ms
5,376 KB
testcase_18 AC 36 ms
5,376 KB
testcase_19 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    int N, M;
    cin >> N >> M;
    deque<int> de;
    rep(i, N) {
        int a;
        cin >> a;
        de.push_back(a);
    }

    rep(i, M) {
        char c;
        cin >> c;
        if (c == 'L') {
            int a = de.front();
            de.pop_front();
            int b = de.front();
            de.pop_front();
            de.push_front(a + b);
            de.push_back(0);
        } else {
            int a = de.back();
            de.pop_back();
            int b = de.back();
            de.pop_back();
            de.push_back(a + b);
            de.push_front(0);
        }
    }

    rep(i, de.size()) { cout << de[i] << " "; }
    cout << endl;
}
0