結果

問題 No.1021 Children in Classrooms
ユーザー hirono999hirono999
提出日時 2020-04-10 23:13:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,841 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 171,628 KB
実行使用メモリ 8,276 KB
最終ジャッジ日時 2023-10-14 04:41:47
合計ジャッジ時間 3,838 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,356 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 41 ms
8,148 KB
testcase_10 AC 42 ms
8,124 KB
testcase_11 AC 41 ms
8,148 KB
testcase_12 AC 43 ms
8,276 KB
testcase_13 AC 43 ms
8,148 KB
testcase_14 AC 43 ms
8,232 KB
testcase_15 AC 33 ms
7,236 KB
testcase_16 AC 35 ms
7,368 KB
testcase_17 AC 34 ms
7,316 KB
testcase_18 AC 39 ms
8,000 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, M;
    cin >> N >> M;
    vec A(N);
    rep(i, N) cin >> A[i];
    string S;
    cin >> S;

    vec state(M + 1);
    rep1(i, M) state[i] += state[i - 1] + (S[i - 1] == 'L' ? -1 : 1);
    ll f_state = state.back();
    vec ans(N);
    sort(ALL(state));
    rep(i, N){
        ll l = 0, r = 0;
        if(state[0] + i < 0) l = abs(state[0] + i);
        if(state.back() + i >= N) r = abs(state.back() + i - N + 1);
        ll now = i + f_state + l - r;
        chmin(now, N - 1), chmax(now, 0LL);
        ans[now] += A[i];
    }

    cout << ans[0];
    rep1(i, N - 1) cout << " " << ans[i];
    print("");

    return 0;
}
0