結果
| 問題 | 
                            No.1021 Children in Classrooms
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-07-25 17:35:09 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 101 ms / 2,000 ms | 
| コード長 | 585 bytes | 
| コンパイル時間 | 623 ms | 
| コンパイル使用メモリ | 67,764 KB | 
| 実行使用メモリ | 9,728 KB | 
| 最終ジャッジ日時 | 2024-06-27 10:41:00 | 
| 合計ジャッジ時間 | 3,313 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#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();){
        cout << *it++;
        if(it == l.end())   break;
        cout << " ";
    }
    cout << endl;
    return 0;
}