結果

問題 No.2623 Room Allocation
ユーザー 👑 OnjoujiTokiOnjoujiToki
提出日時 2024-02-10 00:42:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,397 bytes
コンパイル時間 1,433 ms
コンパイル使用メモリ 140,028 KB
実行使用メモリ 13,368 KB
最終ジャッジ日時 2024-02-10 00:42:47
合計ジャッジ時間 3,720 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 21 ms
6,796 KB
testcase_07 AC 19 ms
6,796 KB
testcase_08 AC 19 ms
6,796 KB
testcase_09 AC 21 ms
6,796 KB
testcase_10 AC 17 ms
12,060 KB
testcase_11 AC 17 ms
12,060 KB
testcase_12 AC 8 ms
7,036 KB
testcase_13 AC 9 ms
7,036 KB
testcase_14 AC 47 ms
13,368 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 58 ms
11,688 KB
testcase_28 AC 24 ms
7,704 KB
testcase_29 AC 17 ms
7,320 KB
testcase_30 AC 49 ms
10,036 KB
testcase_31 AC 7 ms
6,676 KB
testcase_32 AC 15 ms
10,400 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<int, int>> 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<int, int>> 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