結果

問題 No.2623 Room Allocation
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2024-02-29 11:46:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 2,354 ms
コンパイル使用メモリ 207,280 KB
実行使用メモリ 12,700 KB
最終ジャッジ日時 2024-02-29 11:46:12
合計ジャッジ時間 6,435 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 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 21 ms
6,676 KB
testcase_08 AC 21 ms
6,676 KB
testcase_09 AC 21 ms
6,676 KB
testcase_10 AC 15 ms
12,696 KB
testcase_11 AC 16 ms
12,696 KB
testcase_12 AC 9 ms
8,064 KB
testcase_13 AC 9 ms
8,064 KB
testcase_14 AC 46 ms
12,700 KB
testcase_15 AC 28 ms
6,676 KB
testcase_16 AC 9 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 28 ms
6,676 KB
testcase_19 AC 27 ms
6,676 KB
testcase_20 AC 28 ms
6,676 KB
testcase_21 AC 29 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 53 ms
10,368 KB
testcase_28 AC 24 ms
8,448 KB
testcase_29 AC 17 ms
8,064 KB
testcase_30 AC 51 ms
9,344 KB
testcase_31 AC 6 ms
6,676 KB
testcase_32 AC 14 ms
9,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    //客i+X+Yの部屋は客iの部屋と同じ
    ll n, x, y, z, p, ans=0;
    char c;
    cin >> n >> x >> y;
    z = x+y;
    vector<ll> a(z), b(z); //a[i]=z周期でaを望む客の数の和
    for (int i=0; i<n; i++){
        cin >> p >> c;
        if (c == 'A') a[i%z]+=p;
        else b[i%z]+=p;
    }

    //始め、全員Aの部屋にいる
    for (int i=0; i<z; i++) ans += a[i];

    //このうち、Y人をBの部屋に移動させる
    vector<ll> d(z);
    for (int i=0; i<z; i++){
        d[i] = b[i]-a[i];
    }
    sort(d.begin(), d.end(), greater<ll>());
    for (int i=0; i<y; i++){
        ans += d[i];
    }

    cout << ans << endl;

    return 0;
}
0