結果

問題 No.2623 Room Allocation
ユーザー Kaushal_26Kaushal_26
提出日時 2024-02-09 22:59:09
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 2,677 bytes
コンパイル時間 3,015 ms
コンパイル使用メモリ 258,568 KB
実行使用メモリ 12,560 KB
最終ジャッジ日時 2024-02-09 22:59:14
合計ジャッジ時間 4,725 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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
7,936 KB
testcase_07 AC 21 ms
7,936 KB
testcase_08 AC 21 ms
7,936 KB
testcase_09 AC 21 ms
7,936 KB
testcase_10 AC 11 ms
9,436 KB
testcase_11 AC 11 ms
9,436 KB
testcase_12 AC 7 ms
6,676 KB
testcase_13 AC 7 ms
6,676 KB
testcase_14 AC 42 ms
12,560 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 31 ms
6,676 KB
testcase_22 AC 22 ms
6,676 KB
testcase_23 AC 13 ms
6,676 KB
testcase_24 AC 29 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,996 KB
testcase_28 AC 23 ms
7,680 KB
testcase_29 AC 15 ms
6,912 KB
testcase_30 AC 51 ms
10,256 KB
testcase_31 AC 5 ms
6,676 KB
testcase_32 AC 10 ms
7,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef Kaushal_26
        #include <debug.h>
#else
        #include <bits/stdc++.h>

        using namespace std;

        #define clog                    if (0) cerr
        #define lvl(...)                42
        #define dbg(...)                42
#endif

#define int                             long long

#define overload5(a, b, c, d, e, ...)   e
#define FORS(i, a, b, c)                for(int i = (a); i < (int)(b); i += c)
#define FOR1(i, a, b)                   for(int i = (a); i < (int)(b); ++i)
#define F0R(i, a)                       for(int i = (0); i < (int)(a); ++i)
#define ROFS(i, a, b, c)                for(int i = (b) - 1; i >= (int)(a); i -= c)
#define ROF1(i, a, b)                   for(int i = (b) - 1; i >= (int)(a); --i)
#define R0F(i, a)                       for(int i = (a) - 1; i >= (int)(0); --i)
#define FOR(...)                        overload5(__VA_ARGS__, FORS, FOR1, F0R)(__VA_ARGS__)
#define ROF(...)                        overload5(__VA_ARGS__, ROFS, ROF1, R0F)(__VA_ARGS__)
#define REP(i, x)			for(auto &i : x)

template <class T> auto V(const T& value, int size) {
        return vector<T>(size, value);
}

template <class T, class... D> auto V(const T& value, int size, D... w) {
        auto W = V(value, w...);
        return vector<decltype(W)>(size, W);
}

template <class T> bool ckmin(T &a, const T b) {
        return b < a ? a = b, 1 : 0;
}

template<class T> bool ckmax(T &a, const T b) {
        return b > a ? a = b, 1 : 0;
}

void solve() {
        int N, X, Y; cin >> N >> X >> Y;

        int M = X + Y;

        int a[N], b[N];
        FOR(i, N) {
                cin >> a[i];
                char c; cin >> c;
                b[i] = c - 'A';
        }

        auto dp = V<array<int, 2>>({0, 0}, M);
        FOR(i, N) dp[i % M][b[i]] += a[i];
        
        ranges::sort(dp, [&](auto P, auto Q) {
                if(P[0] - P[1] > Q[0] - Q[1]) return 1;
                return 0;
        });
        
        // FOR(i, M) cout << dp[i][0] << " " << dp[i][1] << endl;

        int ret = 0, cur = -1;
        FOR(i, min(M, X)) {
                ret += dp[i][0];
                cur = i;
        }
        ROF(i, M) {
                if(Y == 0) break;
                if(i == cur) break;
                Y--;
                ret += dp[i][1];
        }

        cout << ret << "\n";
}       

signed main() {
        cin.tie(0)->sync_with_stdio(0);

        #ifdef Kaushal_26
                for(int TestCase = 1; ; TestCase++) {
                        clog << endl; dbg(TestCase);
                        solve();
                }
        #else
                solve();
        #endif
        return 0;
}

// 1.77245
0