結果

問題 No.1021 Children in Classrooms
ユーザー granddaifukugranddaifuku
提出日時 2020-06-05 19:56:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 1,204 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 170,192 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-08-22 11:15:07
合計ジャッジ時間 3,455 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 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,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 34 ms
4,376 KB
testcase_10 AC 34 ms
4,376 KB
testcase_11 AC 34 ms
4,400 KB
testcase_12 AC 33 ms
4,384 KB
testcase_13 AC 32 ms
4,380 KB
testcase_14 AC 33 ms
4,384 KB
testcase_15 AC 24 ms
4,380 KB
testcase_16 AC 24 ms
4,380 KB
testcase_17 AC 26 ms
4,384 KB
testcase_18 AC 32 ms
4,480 KB
testcase_19 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld =  long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
    string s;
    cin >> n >> m;
    deque<int> dq;
    rep (i, n) {
        int a;
        cin >> a;
        dq.push_back(a);
    }
    cin >> s;
    rep (i, s.size()) {
        if (s[i] == 'L') {
            int f1 = dq.front();
            dq.pop_front();
            int f2 = dq.front();
            dq.pop_front();
            dq.push_front(f1 + f2);
            dq.push_back(0);
        } else {
            int b1 = dq.back();
            dq.pop_back();
            int b2 = dq.back();
            dq.pop_back();
            dq.push_back(b1 + b2);
            dq.push_front(0);
        }
    }
    while (!dq.empty()) {
        cout << dq.front();
        dq.pop_front();
        if (dq.size() == 0) cout << endl;
        else cout << " ";
    }
    
    return 0;
}

0