結果
問題 | No.2623 Room Allocation |
ユーザー |
![]() |
提出日時 | 2024-02-09 22:26:33 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 171 ms / 2,000 ms |
コード長 | 908 bytes |
コンパイル時間 | 2,535 ms |
コンパイル使用メモリ | 215,276 KB |
実行使用メモリ | 36,460 KB |
最終ジャッジ日時 | 2024-09-28 15:41:09 |
合計ジャッジ時間 | 5,586 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>#ifdef LOCAL#include "./debug.cpp"#else#define debug(...)#define print_line#endifusing namespace std;using ll = long long;int main() {int N, X, Y;cin >> N >> X >> Y;int Z = X + Y;vector<int> P(N), C(N);for (int i = 0; i < N; i++) {char c;cin >> P[i] >> c;C[i] = c == 'B';}vector<vector<ll>> profit(Z, vector<ll>(2));for (int i = 0; i < N; i++) profit[i % Z][C[i]] += P[i];debug(profit);vector<pair<ll, int>> v;for (int i = 0; i < Z; i++) v.push_back(make_pair(profit[i][0] - profit[i][1], i));sort(v.rbegin(), v.rend());debug(v);ll ans = 0;for (int i = 0; i < X; i++) {int idx = v[i].second;ans += profit[idx][0];}for (int i = X; i < Z; i++) {int idx = v[i].second;ans += profit[idx][1];}cout << ans << endl;}