結果

問題 No.1021 Children in Classrooms
ユーザー onsen_manjuuuonsen_manjuuu
提出日時 2020-06-13 18:04:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 1,825 ms
コンパイル使用メモリ 173,128 KB
実行使用メモリ 5,200 KB
最終ジャッジ日時 2023-09-07 23:31:47
合計ジャッジ時間 5,723 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 77 ms
5,020 KB
testcase_10 AC 77 ms
5,072 KB
testcase_11 AC 77 ms
4,952 KB
testcase_12 AC 76 ms
5,200 KB
testcase_13 AC 76 ms
5,024 KB
testcase_14 AC 76 ms
4,976 KB
testcase_15 AC 59 ms
4,644 KB
testcase_16 AC 59 ms
4,716 KB
testcase_17 AC 61 ms
4,748 KB
testcase_18 AC 82 ms
5,068 KB
testcase_19 AC 13 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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