結果

問題 No.2623 Room Allocation
ユーザー maksimmaksim
提出日時 2024-02-09 22:42:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 171,372 KB
実行使用メモリ 11,528 KB
最終ジャッジ日時 2024-02-09 22:42:57
合計ジャッジ時間 3,400 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 21 ms
6,784 KB
testcase_07 AC 20 ms
6,784 KB
testcase_08 AC 21 ms
6,784 KB
testcase_09 AC 20 ms
6,784 KB
testcase_10 AC 13 ms
9,672 KB
testcase_11 AC 12 ms
9,672 KB
testcase_12 AC 7 ms
6,676 KB
testcase_13 AC 7 ms
6,676 KB
testcase_14 AC 43 ms
11,528 KB
testcase_15 AC 30 ms
6,676 KB
testcase_16 AC 9 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 29 ms
6,676 KB
testcase_19 AC 27 ms
6,676 KB
testcase_20 AC 28 ms
6,676 KB
testcase_21 AC 29 ms
6,676 KB
testcase_22 AC 22 ms
6,676 KB
testcase_23 AC 24 ms
6,676 KB
testcase_24 AC 29 ms
6,676 KB
testcase_25 AC 24 ms
6,676 KB
testcase_26 AC 4 ms
6,676 KB
testcase_27 AC 52 ms
9,964 KB
testcase_28 AC 22 ms
7,424 KB
testcase_29 AC 14 ms
6,912 KB
testcase_30 AC 51 ms
9,220 KB
testcase_31 AC 6 ms
6,676 KB
testcase_32 AC 11 ms
7,912 KB
権限があれば一括ダウンロードができます

ソースコード

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