結果

問題 No.2623 Room Allocation
ユーザー 寝癖寝癖
提出日時 2024-02-09 22:35:45
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 1,441 bytes
コンパイル時間 2,838 ms
コンパイル使用メモリ 253,884 KB
実行使用メモリ 17,048 KB
最終ジャッジ日時 2024-02-09 22:35:51
合計ジャッジ時間 5,921 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 52 ms
8,292 KB
testcase_07 AC 62 ms
8,292 KB
testcase_08 AC 64 ms
8,292 KB
testcase_09 AC 65 ms
8,292 KB
testcase_10 AC 24 ms
12,284 KB
testcase_11 AC 19 ms
12,284 KB
testcase_12 AC 11 ms
8,140 KB
testcase_13 AC 13 ms
8,140 KB
testcase_14 AC 146 ms
17,048 KB
testcase_15 AC 94 ms
6,676 KB
testcase_16 AC 25 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 95 ms
6,676 KB
testcase_19 AC 88 ms
6,676 KB
testcase_20 AC 93 ms
6,676 KB
testcase_21 AC 95 ms
6,676 KB
testcase_22 AC 71 ms
6,676 KB
testcase_23 AC 44 ms
6,676 KB
testcase_24 AC 94 ms
6,676 KB
testcase_25 AC 77 ms
6,676 KB
testcase_26 AC 9 ms
6,676 KB
testcase_27 AC 134 ms
17,048 KB
testcase_28 AC 54 ms
10,856 KB
testcase_29 AC 49 ms
8,656 KB
testcase_30 AC 129 ms
12,904 KB
testcase_31 AC 12 ms
6,676 KB
testcase_32 AC 22 ms
12,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

template <class T> using Vec = vector<T>;
template <class T> using Graph = Vec<Vec<T>>;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,n-1,-1)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll A[500000][2];

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;

  int M = X+Y;

  rep(i, N) {
    int p;
    char c;
    cin >> p >> c;
    A[i%M][c-'A'] += p;
  }


  vector<pair<ll, int>> B;
  rep(i, M) B.push_back({A[i][0]-A[i][1], i});
  sort(all(B), greater<pair<ll, int>>());

  ll ans = 0;
  for (auto [_, i]: B) {
    if (X > 0) {
      ans += A[i][0];
      X--;
    } else {
      ans += A[i][1];
      Y--;
    }
  }

  cout << ans << endl;
}
0