結果

問題 No.1021 Children in Classrooms
ユーザー hirono999hirono999
提出日時 2020-04-10 22:02:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,734 bytes
コンパイル時間 2,956 ms
コンパイル使用メモリ 168,556 KB
実行使用メモリ 6,688 KB
最終ジャッジ日時 2023-10-14 00:33:01
合計ジャッジ時間 3,706 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 35 ms
6,580 KB
testcase_10 AC 35 ms
6,612 KB
testcase_11 AC 35 ms
6,576 KB
testcase_12 AC 35 ms
6,608 KB
testcase_13 AC 35 ms
6,568 KB
testcase_14 AC 35 ms
6,688 KB
testcase_15 AC 26 ms
5,764 KB
testcase_16 AC 27 ms
5,772 KB
testcase_17 AC 27 ms
6,012 KB
testcase_18 AC 36 ms
6,608 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;

    ll state = 0;
    ll left = 0, right = 0;
    rep(i, M) state += S[i] == 'L' ? -1 : 1, chmin(left, state), chmax(right, state);

    vec ans(N);
    rep(i, N){
        ll now = i + state;
        if(i + left < 0) now += abs(i + left);
        if(i + right >= N) now -= abs(i + right - N + 1);
        ans[now] += A[i];
    }

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

    return 0;
}
0