結果

問題 No.2623 Room Allocation
ユーザー maksimmaksim
提出日時 2024-02-09 22:42:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 171,888 KB
実行使用メモリ 11,312 KB
最終ジャッジ日時 2024-09-28 15:53:03
合計ジャッジ時間 3,217 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#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