結果

問題 No.1021 Children in Classrooms
ユーザー onsen_manjuuu
提出日時 2020-06-13 18:04:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 1,927 ms
コンパイル使用メモリ 174,032 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-25 16:59:10
合計ジャッジ時間 4,612 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

template<class T> ostream& operator<<(ostream& os, const deque<T> arr){ for(int i = 0; i < (int)arr.size(); i++)cout << arr[i] << (i == (int)arr.size() -1 ? "" : " "); return os;}

int main()
{
    int n, m; cin >> n >> m;
    deque<int> que(n);
    for(int i = 0; i < n; i++)cin >> que[i];
    for(int i = 0; i < m; i++) {
        char c; cin >> c;
        if(c == 'R') {
            int a = que.back(); que.pop_back();
            int b = que.back(); que.pop_back();
            que.push_back(a + b);
            que.push_front(0);
        } else {
            int a = que.front(); que.pop_front();
            int b = que.front(); que.pop_front();
            que.push_front(a + b);
            que.push_back(0);
        }
    }
    cout << que << endl;
}
0