結果
| 問題 |
No.2623 Room Allocation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-11 01:09:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 120 ms / 2,000 ms |
| コード長 | 791 bytes |
| コンパイル時間 | 1,982 ms |
| コンパイル使用メモリ | 203,624 KB |
| 最終ジャッジ日時 | 2025-02-18 17:05:51 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
int main() {
ll N,X,Y;
cin >> N >> X >> Y;
ll mod=X+Y;
vector<ll> cntA(mod,0),cntB(mod,0);
rep(i,N){
ll p;
char c;
cin >> p >> c;
if(c=='A') cntA[i%mod]+=p;
if(c=='B') cntB[i%mod]+=p;
}
vector<ll> cnt(mod);
rep(i,mod) cnt[i]=cntA[i]-cntB[i];
sort(all(cnt));
reverse(all(cnt));
ll ans=0;
rep(i,mod) ans+=cntB[i];
rep(i,X) ans+=cnt[i];
cout << ans << endl;
return 0;
}