結果
問題 | No.2623 Room Allocation |
ユーザー |
![]() |
提出日時 | 2024-02-29 11:46:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 2,048 ms |
コンパイル使用メモリ | 199,700 KB |
最終ジャッジ日時 | 2025-02-19 21:59:13 |
ジャッジサーバーID (参考情報) |
judge1 / 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; }