結果

問題 No.2623 Room Allocation
ユーザー ragnaragna
提出日時 2024-02-09 21:50:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 1,197 bytes
コンパイル時間 4,061 ms
コンパイル使用メモリ 268,052 KB
実行使用メモリ 20,116 KB
最終ジャッジ日時 2024-02-09 21:51:06
合計ジャッジ時間 7,342 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
6,676 KB
testcase_06 AC 59 ms
8,900 KB
testcase_07 AC 60 ms
8,900 KB
testcase_08 AC 56 ms
8,900 KB
testcase_09 AC 56 ms
8,900 KB
testcase_10 AC 47 ms
18,644 KB
testcase_11 AC 47 ms
18,644 KB
testcase_12 AC 17 ms
12,292 KB
testcase_13 AC 35 ms
12,292 KB
testcase_14 AC 153 ms
20,116 KB
testcase_15 AC 94 ms
6,676 KB
testcase_16 AC 23 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 87 ms
6,676 KB
testcase_19 AC 82 ms
6,676 KB
testcase_20 AC 86 ms
6,676 KB
testcase_21 AC 97 ms
6,676 KB
testcase_22 AC 68 ms
6,676 KB
testcase_23 AC 39 ms
6,676 KB
testcase_24 AC 88 ms
6,676 KB
testcase_25 AC 72 ms
6,676 KB
testcase_26 AC 8 ms
6,676 KB
testcase_27 AC 129 ms
19,036 KB
testcase_28 AC 55 ms
11,860 KB
testcase_29 AC 59 ms
13,020 KB
testcase_30 AC 121 ms
13,336 KB
testcase_31 AC 12 ms
6,676 KB
testcase_32 AC 35 ms
16,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using mint=modint998244353;
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrep(i,a,b) for(ll i=(ll)(a-1);i>=(ll)(b);i--)
#define MOD 998244353
//#define MOD 1000000007
#define INF 1e18
#define Pair pair<ll,ll>
//#define PI numbers::pi
//#define E numbers::e
template <typename T> bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};

int main(){
    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];
    vector<Pair> v(x+y,{0,0});
    rep(i,0,n){
        if(c[i]=='A') v[i%(x+y)].first+=p[i];
        else v[i%(x+y)].second+=p[i];
    }
    priority_queue<Pair> pque;
    rep(i,0,x+y) pque.push({v[i].second-v[i].first,i});
    vector<char> w(x+y,'A');
    rep(i,0,y){
        w[pque.top().second]='B';
        pque.pop();
    }
    ll ans=0;
    rep(i,0,x+y){
        if(w[i]=='A') ans+=v[i].first;
        else ans+=v[i].second;
    }
    cout << ans << endl;
}
0