結果

問題 No.2623 Room Allocation
ユーザー 👑 OnjoujiTokiOnjoujiToki
提出日時 2024-02-10 00:43:24
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 2,411 bytes
コンパイル時間 1,928 ms
コンパイル使用メモリ 181,180 KB
実行使用メモリ 19,492 KB
最終ジャッジ日時 2024-02-10 00:43:28
合計ジャッジ時間 3,981 ms
ジャッジサーバーID
(参考情報)
judge12 / 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 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 23 ms
8,520 KB
testcase_07 AC 24 ms
8,520 KB
testcase_08 AC 23 ms
8,520 KB
testcase_09 AC 24 ms
8,520 KB
testcase_10 AC 20 ms
18,536 KB
testcase_11 AC 19 ms
18,536 KB
testcase_12 AC 13 ms
12,184 KB
testcase_13 AC 12 ms
12,184 KB
testcase_14 AC 52 ms
19,492 KB
testcase_15 AC 31 ms
6,676 KB
testcase_16 AC 8 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 30 ms
6,676 KB
testcase_19 AC 28 ms
6,676 KB
testcase_20 AC 29 ms
6,676 KB
testcase_21 AC 30 ms
6,676 KB
testcase_22 AC 24 ms
6,676 KB
testcase_23 AC 14 ms
6,676 KB
testcase_24 AC 30 ms
6,676 KB
testcase_25 AC 25 ms
6,676 KB
testcase_26 AC 5 ms
6,676 KB
testcase_27 AC 61 ms
18,412 KB
testcase_28 AC 27 ms
11,560 KB
testcase_29 AC 19 ms
12,756 KB
testcase_30 AC 57 ms
14,832 KB
testcase_31 AC 8 ms
6,676 KB
testcase_32 AC 19 ms
16,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* 💕💕💕💕💕
💗💗💗💗💗
  /)/)
( . .)
( づ💗

    💗💗💗  💗💗💗
  💗💗💗💗💗💗💗💗💗
  💗💗💗💗💗💗💗💗💗
    💗💗💗💗💗💗💗
      💗💗💗💗💗
        💗💗💗
          💗

*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ranges>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T1, typename T2>
std::istream &operator>>(std::istream &is, std::pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i + 1 != (int)v.size() ? " " : "");
  }
  return os;
}

template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

void solve() {
  int n, x, y;
  std::cin >> n >> x >> y;
  std::vector<std::pair<int, char>> a(n);
  for (auto &[p, c] : a) std::cin >> p >> c;
  std::vector<std::pair<long, long>> cnt(x + y);
  for (int i = 0; i < n; i++) {
    if (a[i].second == 'A')
      cnt[i % (x + y)].first += a[i].first;
    else
      cnt[i % (x + y)].second += a[i].first;
  }
  std::vector<std::pair<long long, long long>> ncnt;
  for (int i = 0; i < x + y; i++) {
    ncnt.emplace_back(cnt[i].first, cnt[i].second);
  }
  std::sort(ncnt.begin(), ncnt.end(), [&](auto &a, auto &b) {
    return a.first - a.second > b.first - b.second;
  });
  long long ans = 0;
  for (auto &[u, v] : ncnt) {
    // std::cout << u << " " << v << std::endl;
  }
  for (int i = 0; i < x; i++) {
    ans += ncnt[i].first;
  }
  for (int j = (int)ncnt.size() - 1; j >= x; j--) {
    ans += ncnt[j].second;
  }
  std::cout << ans << std::endl;
}
int main() {
  int t = 1;
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  // std::cin >> t;
  solve();

  return 0;
}
0