結果

問題 No.1021 Children in Classrooms
ユーザー ei13337ei13337
提出日時 2020-04-10 22:34:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,927 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 113,216 KB
実行使用メモリ 8,052 KB
最終ジャッジ日時 2023-10-14 01:19:47
合計ジャッジ時間 2,826 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 WA -
testcase_09 AC 35 ms
6,588 KB
testcase_10 AC 35 ms
6,620 KB
testcase_11 AC 36 ms
6,588 KB
testcase_12 AC 35 ms
6,612 KB
testcase_13 AC 34 ms
6,568 KB
testcase_14 AC 35 ms
6,648 KB
testcase_15 AC 28 ms
7,048 KB
testcase_16 WA -
testcase_17 AC 30 ms
7,120 KB
testcase_18 WA -
testcase_19 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cassert>
#include <random>
#include <iomanip>
#include <bitset>
#define FOR(i, n, m) for(ll i = n; i < (int)m; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll inf = 1000000000;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    string s;
    cin >> s;
    vector<ll> l, r;
    l.pb(1); r.pb(n);
    ll lp = 1, rp = n;
    REP(i, m) {
        if(lp == rp) {
            if(s[i] == 'L') {
                if(lp != 1) {
                    lp--;
                    rp--;
                }
            } else {
                if(lp != n) {
                    lp++;
                    rp++;
                }
            }
            continue;
        }
        if(s[i] == 'L') {
            if(lp == 1) {
                l.pb(l.back() + 1);
                rp--;
            } else {
                lp--;
                rp--;
            }
        } else {
            if(rp == n) {
                r.pb(r.back() - 1);
                lp++;
            } else {
                lp++;
                rp++;
            }
        }
    }
    vector<ll> ans(n, 0);
    for(ll i = lp; i <= rp; i++) {
        if(i == lp) {
            REP(j, l.size()) ans[i - 1] += a[l[j] - 1];
        } else if(i == rp) {
            REP(j, r.size()) ans[i - 1] += a[r[j] - 1];
        } else {
            ans[i - 1] = a[(int)l.size() + (i - lp) - 1];
        }
    }
    REP(i, n) {
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}
0