結果

問題 No.1021 Children in Classrooms
ユーザー zeronosu77108
提出日時 2020-04-10 23:06:10
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 870 ms
コンパイル使用メモリ 129,244 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 17:28:49
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
using P = pair<char,int>;

int main() {
    int n,m;
    cin >> n >> m;
    deque<int> a;
    for (int i=0; i<n; i++) {
        int ai;
        cin >> ai;
        a.push_back(ai);
    }
    string s;
    cin >> s;

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

    for (auto ai : a) {
        cout << ai << " ";
    }
    cout << endl;

}
0