結果

問題 No.1021 Children in Classrooms
ユーザー rina_1717rina_1717
提出日時 2020-08-22 15:25:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,564 bytes
コンパイル時間 757 ms
コンパイル使用メモリ 98,620 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 09:43:41
合計ジャッジ時間 3,004 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
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 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 8;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rnr(i, a, b) for(int i = int(a); i >= int(b); i--)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n, m; cin >> n >> m;
    ll a[n]; rep(i, n) cin >> a[i];
    string s; cin >> s;
    int l = 0, r = n - 1;
    int now = 0, maxr = 0, minl = 0, peni = 0;
    for(char c : s) {
        if(c == 'L') {
            if(peni > 0) --peni;
            --now;
            if(l < n - 1) {
                if(now < minl) {
                    a[l + 1] += a[l];
                    a[l] = 0;
                    ++l;
                    minl = now;
                }
            }
        } else if(c == 'R') {
            if(peni < n - 1) ++peni;
            ++now;
            if(r > 0) {
                if(now > maxr) {
                    a[r - 1] += a[r];
                    a[r] = 0;
                    --r;
                    maxr = now;
                }
            }
        }
    }
    
    rep(i, peni)
        cout << 0 << ' ';
    rng(i, peni, n) {
        cout << a[i] << ' ';
    }
}
0