結果

問題 No.1021 Children in Classrooms
ユーザー コーヒー太郎コーヒー太郎
提出日時 2020-05-30 09:09:22
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 819 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 31,104 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-24 18:15:08
合計ジャッジ時間 4,491 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N, M;
    int *p;
    char *s;

    scanf("%d %d", &N, &M);
    p = (int *)malloc(sizeof(int) * N);
    s = (char *)malloc(sizeof(char) * (M + 1));

    for(int i = 0; i < N; i++) scanf("%d", &p[i]);
    scanf("%s", s);

    for(int i = 0; i < M; i++){
        if(s[i] == 'L'){
            for(int j = 0; j < N - 1; j++){
                p[j] += p[j + 1];
                p[j + 1] = 0;
            }
        }else if(s[i] == 'R'){
            for(int j = N - 1; j > 0; j--){
                p[j] += p[j - 1];
                p[j - 1] = 0;
            }
        }
    }

    free(s);
    for(int i = 0; i < N; i++){
        if(i == N - 1){
            printf("%d", p[i]);
        }else{
            printf("%d ", p[i]);
        }
    }
    
    return 0;
}
0