結果

問題 No.2623 Room Allocation
ユーザー Fu_LFu_L
提出日時 2024-02-18 15:44:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 1,034 bytes
コンパイル時間 2,395 ms
コンパイル使用メモリ 209,396 KB
実行使用メモリ 14,556 KB
最終ジャッジ日時 2024-02-18 15:44:55
合計ジャッジ時間 4,899 ms
ジャッジサーバーID
(参考情報)
judge16 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 22 ms
7,424 KB
testcase_07 AC 22 ms
7,424 KB
testcase_08 AC 21 ms
7,424 KB
testcase_09 AC 22 ms
7,424 KB
testcase_10 AC 19 ms
12,696 KB
testcase_11 AC 18 ms
12,696 KB
testcase_12 AC 10 ms
8,064 KB
testcase_13 AC 10 ms
8,064 KB
testcase_14 AC 51 ms
14,556 KB
testcase_15 AC 29 ms
6,676 KB
testcase_16 AC 9 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 29 ms
6,676 KB
testcase_22 AC 22 ms
6,676 KB
testcase_23 AC 27 ms
6,676 KB
testcase_24 AC 30 ms
6,676 KB
testcase_25 AC 23 ms
6,676 KB
testcase_26 AC 4 ms
6,676 KB
testcase_27 AC 67 ms
12,160 KB
testcase_28 AC 29 ms
8,960 KB
testcase_29 AC 18 ms
8,448 KB
testcase_30 AC 63 ms
11,008 KB
testcase_31 AC 7 ms
6,676 KB
testcase_32 AC 17 ms
9,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    ll n, x, y;
    cin >> n >> x >> y;
    vector<ll> p(n);
    vector<char> c(n);
    rep(i, 0, n) {
        cin >> p[i] >> c[i];
    }
    ll z = x + y;
    vector<ll> a(z), b(z);
    rep(i, 0, n) {
        if(c[i] == 'A') {
            a[i % z] += p[i];
        } else {
            b[i % z] += p[i];
        }
    }
    vector<ll> idx(z);
    rep(i, 0, z) idx[i] = i;
    auto comp = [&](ll x, ll y) -> bool {
        return (a[x] - b[x]) < (a[y] - b[y]);
    };
    sort(idx.begin(), idx.end(), comp);
    ll ans = 0;
    rep(i, 0, y) {
        ans += b[idx[i]];
    }
    rep(i, y, x + y) {
        ans += a[idx[i]];
    }
    cout << ans << '\n';
}
0