結果

問題 No.1021 Children in Classrooms
ユーザー rina_1717rina_1717
提出日時 2020-08-22 15:56:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,677 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 97,608 KB
実行使用メモリ 5,468 KB
最終ジャッジ日時 2024-04-23 10:11:44
合計ジャッジ時間 3,189 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 72 ms
5,376 KB
testcase_10 AC 72 ms
5,468 KB
testcase_11 AC 73 ms
5,376 KB
testcase_12 AC 71 ms
5,376 KB
testcase_13 AC 70 ms
5,376 KB
testcase_14 AC 71 ms
5,376 KB
testcase_15 AC 54 ms
5,376 KB
testcase_16 AC 55 ms
5,376 KB
testcase_17 AC 56 ms
5,376 KB
testcase_18 AC 77 ms
5,376 KB
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;
                }
            }
        }
    }
    int j = 0;
    rep(i, peni)
        cout << 0 << ' ';
    rng(i, peni, n) {
        if(l + j >= n) {
            cout << 0 << ' ';
        } else {
            cout << a[l + j] << ' ';
        }
        ++j;
    }
}
0