結果

問題 No.2623 Room Allocation
ユーザー k82bk82b
提出日時 2024-02-10 15:55:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 210,244 KB
実行使用メモリ 12,092 KB
最終ジャッジ日時 2024-02-10 15:56:02
合計ジャッジ時間 5,431 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 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 44 ms
6,676 KB
testcase_07 AC 44 ms
6,676 KB
testcase_08 AC 44 ms
6,676 KB
testcase_09 AC 44 ms
6,676 KB
testcase_10 AC 16 ms
11,140 KB
testcase_11 AC 14 ms
11,140 KB
testcase_12 AC 8 ms
7,296 KB
testcase_13 AC 7 ms
7,296 KB
testcase_14 AC 106 ms
12,092 KB
testcase_15 AC 84 ms
6,676 KB
testcase_16 AC 21 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 91 ms
6,676 KB
testcase_19 AC 80 ms
6,676 KB
testcase_20 AC 82 ms
6,676 KB
testcase_21 AC 84 ms
6,676 KB
testcase_22 AC 62 ms
6,676 KB
testcase_23 AC 36 ms
6,676 KB
testcase_24 AC 84 ms
6,676 KB
testcase_25 AC 70 ms
6,676 KB
testcase_26 AC 7 ms
6,676 KB
testcase_27 AC 116 ms
10,236 KB
testcase_28 AC 45 ms
7,936 KB
testcase_29 AC 27 ms
7,424 KB
testcase_30 AC 115 ms
9,216 KB
testcase_31 AC 8 ms
6,676 KB
testcase_32 AC 16 ms
8,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
	int N, X, Y;
	cin >> N >> X >> Y;
	vector<int> P(N);
	vector<char> c(N);
	for (int i = 0; i < N; i++){
		cin >> P[i] >> c[i];
	}
	vector<long long> A(X + Y, 0);
	vector<long long> B(X + Y, 0);
	for (int i = 0; i < N; i++){
		if (c[i] == 'A'){
			A[i % (X + Y)] += P[i];
		}
		if (c[i] == 'B'){
			B[i % (X + Y)] += P[i];
		}
	}
	vector<int> ord(X + Y);
	for (int i = 0; i < X + Y; i++){
		ord[i] = i;
	}
	sort(ord.begin(), ord.end(), [&](int a, int b){return A[a] - B[a] < A[b] - B[b];});
	long long ans = 0;
	for (int i = 0; i < Y; i++){
		ans += B[ord[i]];
	}
	for (int i = Y; i < X + Y; i++){
		ans += A[ord[i]];
	}
	cout << ans << endl;
}
0