結果

問題 No.1021 Children in Classrooms
ユーザー nasu_ysmrnasu_ysmr
提出日時 2020-04-16 13:13:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,197 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 163,720 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 19:09:56
合計ジャッジ時間 3,406 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 77 ms
6,940 KB
testcase_10 AC 76 ms
6,944 KB
testcase_11 AC 81 ms
6,944 KB
testcase_12 AC 81 ms
6,944 KB
testcase_13 AC 82 ms
6,940 KB
testcase_14 AC 82 ms
6,944 KB
testcase_15 AC 61 ms
6,940 KB
testcase_16 AC 59 ms
6,944 KB
testcase_17 AC 63 ms
6,940 KB
testcase_18 AC 82 ms
6,940 KB
testcase_19 AC 13 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M,pos=0,length,R=1,L=1;
    cin >> N >> M;
    int a[N];
    length=N;
    char opr;
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    cin >> opr;
    if(opr=='R'){
        pos=1;
        R++;
    }else{
        pos=0;
        L++;
    }
    length--;
    for(int i=1; i<M; i++){
        cin >> opr;
        if(opr=='R'){
            if(pos==N-length){
                if(length>1){
                    length--;
                    R++;
                    pos++;
                }
            }else{
                pos++;
            }
        }else{
            if(pos==0){
                if(length>1){
                    length--;
                    L++;
                }
            }else{
                pos--;
            }
        }
    }
    for(int i=0; i<L-1; i++){
        a[L-1]+=a[i];
        a[i]=0;
    }
    for(int i=N-1; i>N-R; i--){
        a[N-R]+=a[i];
        a[i]=0;
    }
    for(int i=0; i<pos; i++){
        cout << 0 << " ";
    }
    for(int i=L-1; i<=N-R; i++){
        cout << a[i] << " ";
    }
    for(int i=0; i<(N-length-pos); i++){
        cout << 0 << " ";
    }
    return 0;
}
0