結果

問題 No.2623 Room Allocation
ユーザー miiitomimiiitomi
提出日時 2024-02-09 22:13:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 2,216 ms
コンパイル使用メモリ 209,356 KB
実行使用メモリ 11,164 KB
最終ジャッジ日時 2024-02-09 22:14:00
合計ジャッジ時間 4,251 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 21 ms
6,676 KB
testcase_07 AC 20 ms
6,676 KB
testcase_08 AC 21 ms
6,676 KB
testcase_09 AC 20 ms
6,676 KB
testcase_10 AC 15 ms
11,160 KB
testcase_11 AC 16 ms
11,160 KB
testcase_12 AC 8 ms
7,296 KB
testcase_13 AC 9 ms
7,296 KB
testcase_14 AC 48 ms
11,164 KB
testcase_15 AC 29 ms
6,676 KB
testcase_16 AC 8 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 29 ms
6,676 KB
testcase_19 AC 27 ms
6,676 KB
testcase_20 AC 28 ms
6,676 KB
testcase_21 AC 28 ms
6,676 KB
testcase_22 AC 22 ms
6,676 KB
testcase_23 AC 13 ms
6,676 KB
testcase_24 AC 28 ms
6,676 KB
testcase_25 AC 24 ms
6,676 KB
testcase_26 AC 4 ms
6,676 KB
testcase_27 AC 64 ms
9,216 KB
testcase_28 AC 26 ms
7,552 KB
testcase_29 AC 17 ms
7,296 KB
testcase_30 AC 60 ms
8,320 KB
testcase_31 AC 6 ms
6,676 KB
testcase_32 AC 15 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    ll N, X, Y, M;
    cin >> N >> X >> Y;
    M = X+Y;
    vector<ll> A(M, 0), B(M, 0);
    for (int i = 0; i < N; i++) {
        ll p;
        char c;
        cin >> p >> c;
        if (c == 'A') A[i % M] += p;
        else B[i % M] += p;
    }
    vector<int> v(M);
    for (int i = 0; i < M; i++) v[i] = i;
    auto cmp = [&](const int &l, const int &r) {
        return A[l] - B[l] > A[r] - B[r];
    };
    sort(v.begin(), v.end(), cmp);
    ll ans = 0;
    for (int i = 0; i < M; i++) {
        if (i < X) ans += A[v[i]];
        else ans += B[v[i]];
    }
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int T = 1;
    // cin >> T;
    while (T--) solve();
}
0