結果
問題 | No.2623 Room Allocation |
ユーザー |
![]() |
提出日時 | 2024-02-29 11:46:06 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 1,985 ms |
コンパイル使用メモリ | 207,796 KB |
実行使用メモリ | 12,668 KB |
最終ジャッジ日時 | 2024-09-29 12:40:25 |
合計ジャッジ時間 | 4,771 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int main(){cin.tie(nullptr);ios_base::sync_with_stdio(false);//客i+X+Yの部屋は客iの部屋と同じll n, x, y, z, p, ans=0;char c;cin >> n >> x >> y;z = x+y;vector<ll> a(z), b(z); //a[i]=z周期でaを望む客の数の和for (int i=0; i<n; i++){cin >> p >> c;if (c == 'A') a[i%z]+=p;else b[i%z]+=p;}//始め、全員Aの部屋にいるfor (int i=0; i<z; i++) ans += a[i];//このうち、Y人をBの部屋に移動させるvector<ll> d(z);for (int i=0; i<z; i++){d[i] = b[i]-a[i];}sort(d.begin(), d.end(), greater<ll>());for (int i=0; i<y; i++){ans += d[i];}cout << ans << endl;return 0;}