結果

問題 No.2623 Room Allocation
ユーザー norikamenorikame
提出日時 2024-02-09 22:00:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 3,850 ms
コンパイル使用メモリ 267,344 KB
実行使用メモリ 28,340 KB
最終ジャッジ日時 2024-02-09 22:00:11
合計ジャッジ時間 6,834 ms
ジャッジサーバーID
(参考情報)
judge14 / 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 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 51 ms
10,752 KB
testcase_07 AC 51 ms
10,752 KB
testcase_08 AC 51 ms
10,752 KB
testcase_09 AC 51 ms
10,752 KB
testcase_10 AC 44 ms
26,740 KB
testcase_11 AC 44 ms
26,740 KB
testcase_12 AC 20 ms
15,032 KB
testcase_13 AC 23 ms
15,032 KB
testcase_14 AC 140 ms
28,340 KB
testcase_15 AC 82 ms
6,676 KB
testcase_16 AC 21 ms
6,676 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 82 ms
6,676 KB
testcase_19 AC 81 ms
6,676 KB
testcase_20 AC 81 ms
6,676 KB
testcase_21 AC 83 ms
6,676 KB
testcase_22 AC 72 ms
6,676 KB
testcase_23 AC 35 ms
6,676 KB
testcase_24 AC 83 ms
6,676 KB
testcase_25 AC 67 ms
6,676 KB
testcase_26 AC 7 ms
6,676 KB
testcase_27 AC 152 ms
22,484 KB
testcase_28 AC 66 ms
16,392 KB
testcase_29 AC 41 ms
15,568 KB
testcase_30 AC 144 ms
19,764 KB
testcase_31 AC 14 ms
7,424 KB
testcase_32 AC 38 ms
19,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	vector<int> p(n), c(n);
	rep(i, n) {
		char ci;
		cin >> p[i] >> ci;
		c[i] = ci - 'A';
	}
	int m = x + y;
	vector<vector<ll>> ab(m, vector<ll>(2));
	rep(i, n) ab[i%m][c[i]] += p[i];
	vector<int> ord(m);
	iota(all(ord), 0);
	sort(all(ord), [&](int li, int ri) -> bool { return ab[li][0]-ab[li][1] > ab[ri][0]-ab[ri][1]; });
	ll res = 0;
	rep(i, m) {
		if (i < x) res += ab[ord[i]][0];
		else res += ab[ord[i]][1];
	}
	cout << res << endl;
	return 0;
}
0