結果

問題 No.1021 Children in Classrooms
ユーザー catuppercatupper
提出日時 2020-04-10 22:03:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 72,508 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-14 00:35:23
合計ジャッジ時間 2,893 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 64 ms
4,348 KB
testcase_10 AC 67 ms
4,356 KB
testcase_11 AC 68 ms
4,348 KB
testcase_12 AC 67 ms
4,364 KB
testcase_13 AC 63 ms
4,348 KB
testcase_14 AC 64 ms
4,352 KB
testcase_15 AC 49 ms
4,380 KB
testcase_16 AC 50 ms
4,352 KB
testcase_17 AC 55 ms
4,352 KB
testcase_18 AC 72 ms
4,348 KB
testcase_19 AC 6 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int n, m;
string s;
int a[220000];

int main(){
    cin >> n >> m;
    for(int i = 0;i < n;i++)cin >> a[i];
    int l = 0, r = n-1;
    cin >> s;
    for(char c:s){
        if(c == 'R'){
            if(r == 0)continue;
            if(0 <= r-1 && r < n){
                a[r-1] += a[r];
                a[r] = 0;
            }
            l--,r--;
        }
        else{
            if(l == n-1)continue;
            if(0 <= l && l+1 < n){
                a[l+1] += a[l];
                a[l] = 0;
            }
            l++,r++;
        }
    }
    for(int i = l;i <= r;i++){
        if(0 <= i && i < n)cout << a[i] << " ";
        else cout << 0 << " ";
    }cout << endl;
    return 0;
}
0