結果

問題 No.2623 Room Allocation
ユーザー Today03Today03
提出日時 2024-02-09 22:26:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 908 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 215,392 KB
実行使用メモリ 36,304 KB
最終ジャッジ日時 2024-02-09 22:26:39
合計ジャッジ時間 5,020 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 1 ms
6,548 KB
testcase_04 AC 1 ms
6,548 KB
testcase_05 AC 1 ms
6,548 KB
testcase_06 AC 55 ms
12,616 KB
testcase_07 AC 66 ms
12,616 KB
testcase_08 AC 64 ms
12,616 KB
testcase_09 AC 65 ms
12,616 KB
testcase_10 AC 103 ms
35,216 KB
testcase_11 AC 47 ms
35,216 KB
testcase_12 AC 25 ms
19,592 KB
testcase_13 AC 52 ms
19,592 KB
testcase_14 AC 159 ms
36,304 KB
testcase_15 AC 96 ms
6,548 KB
testcase_16 AC 21 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 84 ms
6,548 KB
testcase_19 AC 79 ms
6,548 KB
testcase_20 AC 83 ms
6,548 KB
testcase_21 AC 81 ms
6,548 KB
testcase_22 AC 62 ms
6,548 KB
testcase_23 AC 36 ms
6,548 KB
testcase_24 AC 82 ms
6,548 KB
testcase_25 AC 67 ms
6,548 KB
testcase_26 AC 8 ms
6,548 KB
testcase_27 AC 140 ms
30,668 KB
testcase_28 AC 70 ms
21,696 KB
testcase_29 AC 46 ms
20,408 KB
testcase_30 AC 138 ms
24,672 KB
testcase_31 AC 26 ms
9,376 KB
testcase_32 AC 77 ms
27,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#ifdef LOCAL
#include "./debug.cpp"
#else
#define debug(...)
#define print_line
#endif
using namespace std;
using ll = long long;

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    int Z = X + Y;

    vector<int> P(N), C(N);
    for (int i = 0; i < N; i++) {
        char c;
        cin >> P[i] >> c;
        C[i] = c == 'B';
    }

    vector<vector<ll>> profit(Z, vector<ll>(2));
    for (int i = 0; i < N; i++) profit[i % Z][C[i]] += P[i];
    debug(profit);

    vector<pair<ll, int>> v;
    for (int i = 0; i < Z; i++) v.push_back(make_pair(profit[i][0] - profit[i][1], i));
    sort(v.rbegin(), v.rend());
    debug(v);

    ll ans = 0;
    for (int i = 0; i < X; i++) {
        int idx = v[i].second;
        ans += profit[idx][0];
    }
    for (int i = X; i < Z; i++) {
        int idx = v[i].second;
        ans += profit[idx][1];
    }

    cout << ans << endl;
}
0