結果

問題 No.2623 Room Allocation
ユーザー hiikunZhiikunZ
提出日時 2024-07-14 08:17:41
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 2,841 ms
コンパイル使用メモリ 208,420 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-07-14 08:17:48
合計ジャッジ時間 6,367 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
constexpr ll MAX = 2000000000000000000;
constexpr ld PI = 3.14159265358979;
constexpr ll MOD = 998244353;//2024948111;
ld dotorad(ld K){ return PI * K / 180.0; }
ld radtodo(ld K){ return K * 180.0 / PI; }
mt19937 mt;
void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); }

int main(){
    ll N,X,Y;
    cin >> N >> X >> Y;
    vector<ll> P(N);
    vector<char> C(N);
    for(ll i = 0; i < N; i++){
        cin >> P[i] >> C[i];
    }
    vector<ll> F(X + Y,0);
    ll base = 0;
    for(ll i = 0;i < N;i++){
        if(C[i] == 'B') F[i % (X + Y)] += P[i];
        else{
            F[i % (X + Y)] -= P[i];
            base += P[i];
        }
    }
    sort(F.begin(),F.end());
    for(ll y = 0;y < Y;y++){
        base += F[X + Y - 1 - y];
    }
    cout << base << endl;
}
0