結果

問題 No.1021 Children in Classrooms
ユーザー face4
提出日時 2020-07-25 17:36:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 67,072 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-06-27 10:43:58
合計ジャッジ時間 2,766 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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