結果
| 問題 | 
                            No.2623 Room Allocation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-02-10 19:55:20 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 645 bytes | 
| コンパイル時間 | 2,123 ms | 
| コンパイル使用メモリ | 200,668 KB | 
| 最終ジャッジ日時 | 2025-02-19 04:41:50 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 3 | 
| other | WA * 20 RE * 10 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
	int N, X, Y;
	cin >> N >> X >> Y;
	std::vector A(N, vector(2, 0ll));
	for (int i = 0; i < N; i ++) {
		ll p; char c;
		cin >> p >> c;
		int j = i % (X + Y);
		A[j][c == 'B'] += p;
	}
	ll ans = 0;
	for (auto& a : A) ans += a[0];
	cout << ans << endl;
	vector<ll> D(min(N, X + Y));
	for (int i = 0; i < min(N, X + Y); i ++) {
		D[i] = A[i][0] - A[i][1];
	}
	sort(D.begin(), D.end());
	int fl = 0;
	for (int i = 0; i < N - X; i ++) {
		ans -= D[fl++];
	}
	while (fl < Y && fl < D.size()) {
		if (D[fl] > 0) break;
		ans -= D[fl];
		fl ++;
	}
	cout << ans << endl;
}