結果

問題 No.1021 Children in Classrooms
ユーザー kcz146kcz146
提出日時 2020-06-19 00:02:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,251 bytes
コンパイル時間 1,883 ms
コンパイル使用メモリ 202,016 KB
実行使用メモリ 5,420 KB
最終ジャッジ日時 2023-09-16 12:29:52
合計ジャッジ時間 3,538 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 31 ms
5,052 KB
testcase_10 AC 30 ms
4,992 KB
testcase_11 AC 30 ms
4,872 KB
testcase_12 AC 30 ms
5,004 KB
testcase_13 AC 30 ms
4,884 KB
testcase_14 AC 30 ms
4,984 KB
testcase_15 AC 22 ms
4,548 KB
testcase_16 AC 23 ms
4,732 KB
testcase_17 AC 24 ms
4,692 KB
testcase_18 AC 31 ms
5,420 KB
testcase_19 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;
    string s;
    cin >> s;

    ll i = 0, j = 0, l = 0, r = n-1;
    for(auto &c: s) {
        switch(c) {
            case 'L':
                if(++j, --i < 0) {
                    i = 0;
                    if(j == n) {
                        j = n-1;
                        continue;
                    }
                    ++l;
                    a[l] += a[l-1];
                }
                break;
            case 'R':
                if(++i, --j < 0) {
                    j = 0;
                    if(i == n) {
                        i = n-1;
                        continue;
                    }
                    --r;
                    a[r] += a[r+1];
                }
                break;
        }
    }
    for(ll k=0; k<i; k++) cout << 0 << ' ';
    for(ll k=l; k<=r; k++) cout << a[k] << ' ';
    for(ll k=0; k<j; k++) cout << 0 << ' ';
    cout << endl;

}
0