結果

問題 No.2623 Room Allocation
コンテスト
ユーザー maksim
提出日時 2024-02-09 22:42:43
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 32 ms / 2,000 ms
+ 228µs
コード長 914 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 954 ms
コンパイル使用メモリ 185,072 KB
実行使用メモリ 11,644 KB
最終ジャッジ日時 2026-09-05 16:50:28
合計ジャッジ時間 4,417 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define app push_back
#ifdef LOCAL
#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << '\n';}(#__VA_ARGS__, ":", __VA_ARGS__)
#else
#define debug(...)
#endif
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
    {
        int n,x,y;cin>>n>>x>>y;
        int c[n];char d[n];
        for(int i=0;i<n;++i) {cin>>c[i]>>d[i];}
        pair<int,int> u[x+y]={};
        for(int i=0;i<n;++i)
        {
            if(d[i]=='A') {u[i%(x+y)].first+=c[i];} else {u[i%(x+y)].second+=c[i];}
        }
        int res=0;
        sort(u,u+x+y,[&](pair<int,int> a1,pair<int,int> b1) {return a1.first-a1.second>b1.first-b1.second;});
        for(int i=0;i<x+y;++i) {if(i<x) res+=u[i].first; else res+=u[i].second;}
        cout<<res<<'\n';
    }
    return 0;
}
0