結果

問題 No.1021 Children in Classrooms
ユーザー kappybarkappybar
提出日時 2020-04-10 21:38:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 1,060 bytes
コンパイル時間 1,597 ms
コンパイル使用メモリ 170,908 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-13 23:40:33
合計ジャッジ時間 3,552 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,356 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 68 ms
4,376 KB
testcase_10 AC 67 ms
4,352 KB
testcase_11 AC 67 ms
4,352 KB
testcase_12 AC 65 ms
4,352 KB
testcase_13 AC 65 ms
4,356 KB
testcase_14 AC 65 ms
4,368 KB
testcase_15 AC 52 ms
4,352 KB
testcase_16 AC 51 ms
4,352 KB
testcase_17 AC 53 ms
4,476 KB
testcase_18 AC 71 ms
4,480 KB
testcase_19 AC 7 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    deque<int> a(n);
    rep(i,n) cin >> a[i];
    string s;
    cin >> s;
    int l=0,r=0;
    rep(i,m){
        if(s[i] =='L'){
            if(l==0){
                if(a.size() == 1) continue;
                else{
                    a[1] += a[0];
                    a.pop_front();
                    r++;
                }
            }else{
                --l;++r;
            }
        }else{
            if(r==0){
                if(a.size() == 1) continue;
                else{
                    a[a.size()-2] += a[a.size()-1];
                    a.pop_back();
                    ++l;
                }
            }else{
                --r;++l;
            }
        }
    }
    rep(i,l) cout << 0 << " " ;
    rep(i,a.size()) cout << a[i] << " ";
    rep(i,r) cout << 0 << " " ;
    cout << endl;
    return 0;
}
0