結果
問題 | No.2623 Room Allocation |
ユーザー |
![]() |
提出日時 | 2024-02-14 13:51:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 778 bytes |
コンパイル時間 | 2,265 ms |
コンパイル使用メモリ | 203,824 KB |
最終ジャッジ日時 | 2025-02-19 13:01:33 |
ジャッジサーバー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; }