結果
問題 |
No.2623 Room Allocation
|
ユーザー |
|
提出日時 | 2024-02-10 19:57:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 143 ms / 2,000 ms |
コード長 | 656 bytes |
コンパイル時間 | 2,214 ms |
コンパイル使用メモリ | 202,636 KB |
最終ジャッジ日時 | 2025-02-19 04:42:00 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#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 < min(Y, N - X); i ++) { ans -= D[fl++]; } while (fl < Y && fl < D.size()) { if (D[fl] > 0) break; ans -= D[fl]; fl ++; } cout << ans << endl; }