結果

問題 No.2482 Sandglasses
ユーザー suisensuisen
提出日時 2023-09-22 23:37:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 1,213 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 84,844 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-04-28 09:03:39
合計ジャッジ時間 7,816 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 157 ms
6,528 KB
testcase_04 AC 150 ms
6,528 KB
testcase_05 AC 150 ms
6,528 KB
testcase_06 AC 151 ms
6,528 KB
testcase_07 AC 149 ms
6,528 KB
testcase_08 AC 146 ms
6,528 KB
testcase_09 AC 148 ms
6,528 KB
testcase_10 AC 151 ms
6,528 KB
testcase_11 AC 151 ms
6,528 KB
testcase_12 AC 153 ms
6,528 KB
testcase_13 AC 147 ms
6,528 KB
testcase_14 AC 150 ms
6,528 KB
testcase_15 AC 149 ms
6,528 KB
testcase_16 AC 153 ms
6,656 KB
testcase_17 AC 147 ms
6,528 KB
testcase_18 AC 150 ms
6,528 KB
testcase_19 AC 146 ms
6,528 KB
testcase_20 AC 147 ms
6,528 KB
testcase_21 AC 149 ms
6,656 KB
testcase_22 AC 146 ms
6,528 KB
testcase_23 AC 152 ms
6,528 KB
testcase_24 AC 149 ms
6,528 KB
testcase_25 AC 150 ms
6,528 KB
testcase_26 AC 151 ms
6,528 KB
testcase_27 AC 149 ms
6,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
    int n, k, t;
    std::cin >> n >> k >> t;

    std::vector<int8_t> a(n);
    for (int i = 0; i < n; ++i) {
        char c;
        std::cin >> c;
        a[i] = (c == 'B');
    }
    std::vector<int> b(n);
    for (int &e : b) std::cin >> e;

    const int q = t / (2 * k), r = t % (2 * k);

    std::vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        c[i] = b[i];
        int rt = r;
        bool state = a[i];
        while (rt) {
            int p = state ? k - c[i] : c[i];
            int d = std::min(rt, p);
            if (state) {
                c[i] += d;
            } else {
                c[i] -= d;
            }
            rt -= d;
            state = not state;
        }
    }
    std::sort(c.begin(), c.end());

    std::vector<int> p(n);
    std::iota(p.begin(), p.end(), 0);
    std::sort(p.begin(), p.end(), [&](int i, int j) { return b[i] < b[j]; });

    std::vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        ans[p[i]] = c[i];
    }

    for (int i = 0; i < n; ++i) {
        std::cout << ans[i];
        if (i + 1 != n) std::cout << ' ';
    }
    std::cout << '\n';
}
0