結果

問題 No.2623 Room Allocation
ユーザー MMMM
提出日時 2024-02-09 22:39:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 3,998 ms
コンパイル使用メモリ 231,776 KB
実行使用メモリ 14,524 KB
最終ジャッジ日時 2024-02-09 22:39:40
合計ジャッジ時間 5,937 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 43 ms
6,676 KB
testcase_07 AC 44 ms
6,676 KB
testcase_08 AC 44 ms
6,676 KB
testcase_09 AC 44 ms
6,676 KB
testcase_10 AC 16 ms
14,524 KB
testcase_11 AC 16 ms
14,524 KB
testcase_12 AC 5 ms
8,704 KB
testcase_13 AC 10 ms
8,704 KB
testcase_14 AC 124 ms
14,524 KB
testcase_15 AC 82 ms
6,676 KB
testcase_16 AC 21 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 83 ms
6,676 KB
testcase_19 AC 77 ms
6,676 KB
testcase_20 AC 81 ms
6,676 KB
testcase_21 AC 85 ms
6,676 KB
testcase_22 AC 64 ms
6,676 KB
testcase_23 AC 36 ms
6,676 KB
testcase_24 AC 84 ms
6,676 KB
testcase_25 AC 66 ms
6,676 KB
testcase_26 AC 8 ms
6,676 KB
testcase_27 AC 107 ms
13,340 KB
testcase_28 AC 42 ms
8,928 KB
testcase_29 AC 26 ms
8,752 KB
testcase_30 AC 102 ms
9,528 KB
testcase_31 AC 8 ms
6,676 KB
testcase_32 AC 20 ms
12,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define ld long double
using namespace std;
using namespace atcoder;
using ll = long long;
const ll mod = 998244353;
using mint = modint998244353;
using Graph = vector<vector<pair<int,int>>>;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};

int main(){
  int N,X,Y; cin >> N >> X >> Y;
  int M = X + Y;
  vector<ll> A(M),B(M);
  for(int i = 0; i < N; i++){
    int p; char c; cin >> p >> c;
    if(c == 'A') A[i%M] += p;
    else B[i%M] += p;
  }
  
  ll ans = 0;
  priority_queue<ll> pq;
  for(int i = 0; i < M; i++){
    ans += A[i];
    pq.push(B[i]-A[i]);
  }
  for(int i = 0; i < Y; i++){
    ans += pq.top();
    pq.pop();
  }
  
  cout << ans << endl;
}
0