結果

問題 No.1021 Children in Classrooms
ユーザー kyort0nkyort0n
提出日時 2020-04-10 21:35:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,308 bytes
コンパイル時間 1,367 ms
コンパイル使用メモリ 164,936 KB
実行使用メモリ 5,264 KB
最終ジャッジ日時 2023-10-13 23:34:52
合計ジャッジ時間 3,162 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,356 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 32 ms
5,092 KB
testcase_10 AC 32 ms
5,144 KB
testcase_11 AC 32 ms
5,180 KB
testcase_12 AC 30 ms
5,112 KB
testcase_13 AC 32 ms
5,180 KB
testcase_14 AC 31 ms
5,264 KB
testcase_15 AC 25 ms
4,736 KB
testcase_16 AC 25 ms
4,808 KB
testcase_17 AC 24 ms
4,780 KB
testcase_18 AC 32 ms
5,244 KB
testcase_19 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll a[300000];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    string S;
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> a[i];
    cin >> S;
    ll l = 0;
    for(auto c : S) {
        if(c == 'L') {
            if(0 <= l and l + 1 < N) {
                a[l+1] += a[l];
                a[l] = 0;
            }
            l++;
            chmin(l, N - 1);
        } else {
            if(l+N-2 >= 0 and l+N-1 < N) {
                a[l+N-2] += a[l+N-1];
                a[l+N-1] = 0;
            }
            l--;
            chmax(l, -N + 1);
        }
    }
    for(ll i = 0; i < N; i++) {
        if(i != 0) cout << " ";
        if(l + i < 0 or i + l >= N) cout << 0;
        else cout << a[i+l];
    }
    cout << endl;
    return 0;
}
0