結果
| 問題 |
No.2623 Room Allocation
|
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2024-02-09 22:26:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 197 ms / 2,000 ms |
| コード長 | 908 bytes |
| コンパイル時間 | 2,077 ms |
| コンパイル使用メモリ | 207,872 KB |
| 最終ジャッジ日時 | 2025-02-19 03:51:14 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#ifdef LOCAL
#include "./debug.cpp"
#else
#define debug(...)
#define print_line
#endif
using 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;
}
Today03