結果

問題 No.1021 Children in Classrooms
ユーザー face4face4
提出日時 2020-07-25 17:36:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 68,264 KB
実行使用メモリ 9,656 KB
最終ジャッジ日時 2023-09-09 18:06:05
合計ジャッジ時間 2,966 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 94 ms
9,616 KB
testcase_10 AC 93 ms
9,656 KB
testcase_11 AC 93 ms
9,652 KB
testcase_12 AC 91 ms
9,616 KB
testcase_13 AC 91 ms
9,604 KB
testcase_14 AC 91 ms
9,588 KB
testcase_15 AC 72 ms
8,060 KB
testcase_16 AC 73 ms
8,396 KB
testcase_17 AC 75 ms
8,336 KB
testcase_18 AC 97 ms
9,612 KB
testcase_19 AC 17 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<list>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    list<int> l;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        l.push_back(x);
    }
    while(m--){
        char c; cin >> c;
        if(c == 'L')    *(++l.begin()) += l.front(), l.pop_front(), l.push_back(0);
        else            *(----l.end()) += l.back(), l.pop_back(), l.push_front(0);
    }
    for(auto it = l.begin(); it != l.end(); it != l.end()){
        cout << *it++, cout << (it == l.end() ? "\n" : " ");
    }
    return 0;
}
0