結果
問題 | No.2623 Room Allocation |
ユーザー |
![]() |
提出日時 | 2024-02-18 15:44:03 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 1,034 bytes |
コンパイル時間 | 2,414 ms |
コンパイル使用メモリ | 208,684 KB |
実行使用メモリ | 14,400 KB |
最終ジャッジ日時 | 2024-09-29 00:39:51 |
合計ジャッジ時間 | 4,172 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using P = pair<ll, ll>;#define rep(i, a, b) for(ll i = a; i < b; ++i)#define rrep(i, a, b) for(ll i = a; i >= b; --i)constexpr ll inf = 4e18;struct SetupIO {SetupIO() {ios::sync_with_stdio(0);cin.tie(0);cout << fixed << setprecision(30);}} setup_io;int main(void) {ll n, x, y;cin >> n >> x >> y;vector<ll> p(n);vector<char> c(n);rep(i, 0, n) {cin >> p[i] >> c[i];}ll z = x + y;vector<ll> a(z), b(z);rep(i, 0, n) {if(c[i] == 'A') {a[i % z] += p[i];} else {b[i % z] += p[i];}}vector<ll> idx(z);rep(i, 0, z) idx[i] = i;auto comp = [&](ll x, ll y) -> bool {return (a[x] - b[x]) < (a[y] - b[y]);};sort(idx.begin(), idx.end(), comp);ll ans = 0;rep(i, 0, y) {ans += b[idx[i]];}rep(i, y, x + y) {ans += a[idx[i]];}cout << ans << '\n';}