結果
| 問題 |
No.2623 Room Allocation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-09 21:52:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 2,000 ms |
| コード長 | 665 bytes |
| コンパイル時間 | 1,548 ms |
| コンパイル使用メモリ | 173,796 KB |
| 実行使用メモリ | 9,476 KB |
| 最終ジャッジ日時 | 2024-09-28 15:08:26 |
| 合計ジャッジ時間 | 3,409 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll n, x, y, cx, cy;
cin >> n >> x >> y;
vector<pair<ll,ll>> a(x + y);
for(int i = 0; i < n; i++){
ll p;
char c;
cin >> p >> c;
if(c == 'A') a[i % (x + y)].first += p;
else a[i % (x + y)].second += p;
}
sort(a.begin(), a.end(), [&](pair<ll,ll> lhs, pair<ll,ll> rhs){
return lhs.first - lhs.second > rhs.first - rhs.second;
});
ll ans = 0;
for(int i = 0; i < x + y; i++){
ans += i < x ? a[i].first : a[i].second;
}
cout << ans << '\n';
}