結果

問題 No.1021 Children in Classrooms
ユーザー musuchika3musuchika3
提出日時 2020-04-11 13:44:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 3,215 bytes
コンパイル時間 1,632 ms
コンパイル使用メモリ 170,832 KB
実行使用メモリ 6,832 KB
最終ジャッジ日時 2023-10-19 03:33:52
合計ジャッジ時間 3,718 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 78 ms
6,832 KB
testcase_10 AC 77 ms
6,832 KB
testcase_11 AC 77 ms
6,832 KB
testcase_12 AC 77 ms
6,832 KB
testcase_13 AC 76 ms
6,832 KB
testcase_14 AC 76 ms
6,832 KB
testcase_15 AC 58 ms
5,920 KB
testcase_16 AC 59 ms
5,928 KB
testcase_17 AC 61 ms
6,252 KB
testcase_18 AC 82 ms
6,832 KB
testcase_19 AC 8 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using pii = pair<int, int>;

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

//pow(llpow,modpow)
template <class T>
ll llpow(ll x, T n)
{
    ll ans = 1;
    if (x == 0)
        ans = 0;
    while (n)
    {
        if (n & 1)
            ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
template <class T>
inline T gcd(T x, T y)
{
    if (y == 0)
        return x;
    else
    {
        return gcd(y, x % y);
    }
}
//最小公倍数
template <class T>
inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
//逆元
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL << 60;
int main()
{
    int n, m;
    cin >> n >> m;
    vll a(n);
    rep(i, 0, n) cin >> a[i];
    string s;
    cin >> s;
    //配列上
    int rl = 0, rr = n - 1;
    //論理的
    int l = 0, r = n - 1;
    rep(i, 0, s.size())
    {
        if (s[i] == 'L')
        {
            if (abs(r - l) >= 1)
            {
                if (l == 0)
                {
                    r--;
                    a[rl + 1]+= a[rl];
                    a[rl] = 0;
                    rl++;
                }
                else
                {
                    r--;
                    l--;
                }
            }
            else
            {
                if (l == 0)
                    continue;
                else
                {
                    r--;
                    l--;
                }
            }
        }
        else
        {
            if (abs(r - l) >= 1)
            {
                if (r == (n - 1))
                {
                    l++;
                    a[rr - 1]+= a[rr];
                    a[rr] = 0;
                    rr--;
                }
                else
                {
                    r++;
                    l++;
                }
            }
            else
            {
                if (r == n - 1)
                    continue;
                else
                {
                    r++;
                    l++;
                }
            }
        }
    }
    vll ans(n,0);
    rep(i,0,n){
        if(i>=l&&i<=r){
            ans[i]=a[rl+(i-l)];
        }
        else{
            ans[i]=0;
        }
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}
0