結果

問題 No.1021 Children in Classrooms
ユーザー phsplsphspls
提出日時 2020-04-11 11:43:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,425 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 169,888 KB
実行使用メモリ 5,304 KB
最終ジャッジ日時 2023-10-19 00:32:37
合計ジャッジ時間 4,247 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    string s;
    cin >> s;

    int minval = 0;
    int minpos = 0;
    int maxval = 0;
    int maxpos = 0;
    int total = 0;
    rep(i, s.length()) {
        bool left = s[i] == 'L';
        if(left) {
            total -= 1;
            if(minval > total) {
                minval = total;
                minpos = i;
            }
        } else {
            total += 1;
            if(maxval < total) {
                maxval = total;
                maxpos = i;
            }
        }
    }
    vector<int> result(n, 0);
    rep(i, n) {
        if(minval + i < 0) {
            if(maxval + i >= n) {
                if(minpos < maxpos) {
                    result[n - 1  - (maxval - total)] += a[i];
                } else {
                    result[0  + (total - minval)] += a[i];
                }
            } else {
                result[0  + (total - minval)] += a[i];
            }
        } else {
            if(maxval + i >= n) {
                result[n - 1 - (maxval - total)] += a[i];
            } else {
                result[i + total] += a[i];
            }
        }
    }
    rep(i, n) {
        cout << result[i];
        if(i < n-1) cout << " ";
    }
    cout << "\n";
}
0