結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 RE -
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 RE -
testcase_06 AC 21 ms
8,520 KB
testcase_07 AC 19 ms
8,520 KB
testcase_08 AC 19 ms
8,520 KB
testcase_09 AC 19 ms
8,520 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 33 ms
6,676 KB
testcase_16 AC 8 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 27 ms
6,676 KB
testcase_19 AC 26 ms
6,676 KB
testcase_20 AC 27 ms
6,676 KB
testcase_21 AC 30 ms
6,676 KB
testcase_22 AC 23 ms
6,676 KB
testcase_23 AC 14 ms
6,676 KB
testcase_24 AC 27 ms
6,676 KB
testcase_25 AC 25 ms
6,676 KB
testcase_26 AC 4 ms
6,676 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

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);
  assert(x + y <= n);
  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