結果

問題 No.2482 Sandglasses
ユーザー suisensuisen
提出日時 2023-09-22 23:44:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 979 ms
コンパイル使用メモリ 85,872 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-04-28 09:03:42
合計ジャッジ時間 8,062 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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
7,296 KB
testcase_04 AC 157 ms
7,296 KB
testcase_05 AC 155 ms
7,296 KB
testcase_06 AC 155 ms
7,296 KB
testcase_07 AC 149 ms
7,424 KB
testcase_08 AC 159 ms
7,296 KB
testcase_09 AC 156 ms
7,424 KB
testcase_10 AC 157 ms
7,424 KB
testcase_11 AC 158 ms
7,296 KB
testcase_12 AC 157 ms
7,424 KB
testcase_13 AC 158 ms
7,296 KB
testcase_14 AC 157 ms
7,296 KB
testcase_15 AC 154 ms
7,296 KB
testcase_16 AC 157 ms
7,296 KB
testcase_17 AC 154 ms
7,296 KB
testcase_18 AC 154 ms
7,424 KB
testcase_19 AC 156 ms
7,296 KB
testcase_20 AC 153 ms
7,296 KB
testcase_21 AC 152 ms
7,296 KB
testcase_22 AC 156 ms
7,296 KB
testcase_23 AC 155 ms
7,296 KB
testcase_24 AC 162 ms
7,296 KB
testcase_25 AC 158 ms
7,296 KB
testcase_26 AC 160 ms
7,424 KB
testcase_27 AC 157 ms
7,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    std::vector<char> a(n);
    for (auto &e : a) std::cin >> e;
    std::vector<long long> b(n);
    for (auto &e : b) std::cin >> e;

    std::vector<int> c(n);
    for (int i = 0; i < n; ++i) c[i] = std::abs(((k + (a[i] == 'B' ? -b[i] : +b[i]) - t) % (2 * k) + 2 * k) % (2 * k) - k);
    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] << " \n"[i == n - 1];
}
0