結果
問題 | No.2623 Room Allocation |
ユーザー |
![]() |
提出日時 | 2024-02-14 13:51:44 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 778 bytes |
コンパイル時間 | 2,393 ms |
コンパイル使用メモリ | 211,100 KB |
実行使用メモリ | 26,720 KB |
最終ジャッジ日時 | 2024-09-28 18:54:12 |
合計ジャッジ時間 | 4,597 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;void fast_io() {ios::sync_with_stdio(false);std::cin.tie(nullptr);}int main() {fast_io();int n, x, y;cin >> n >> x >> y;vector<vector<long long>> cnt(x + y, vector<long long>(2));for (int i = 0; i < n; i++) {int p;char c;cin >> p >> c;cnt[i % (x + y)][c - 'A'] += p;}vector<int> idx(x + y);iota(idx.begin(), idx.end(), 0);sort(idx.begin(), idx.end(), [&](int i, int j) {return cnt[i][0] - cnt[i][1] > cnt[j][0] - cnt[j][1];});long long ans = 0;for (int i = 0; i < x; i++) {ans += cnt[idx[i]][0];}for (int i = x; i < x + y; i++) {ans += cnt[idx[i]][1];}cout << ans << endl;}