結果

問題 No.1021 Children in Classrooms
ユーザー catuppercatupper
提出日時 2020-04-10 22:01:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 966 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 72,544 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-10-14 00:31:20
合計ジャッジ時間 2,364 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 || r >= n)continue;
            a[r-1] += a[r];
            a[r] = 0;
            l--,r--;
        }
        else{
            if(l == n-1 || l < 0)continue;
            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