結果
| 問題 |
No.2623 Room Allocation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-10 00:42:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,397 bytes |
| コンパイル時間 | 1,535 ms |
| コンパイル使用メモリ | 135,084 KB |
| 最終ジャッジ日時 | 2025-02-19 04:19:47 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 12 |
ソースコード
/* 💕💕💕💕💕
💗💗💗💗💗
/)/)
( . .)
( づ💗
💗💗💗 💗💗💗
💗💗💗💗💗💗💗💗💗
💗💗💗💗💗💗💗💗💗
💗💗💗💗💗💗💗
💗💗💗💗💗
💗💗💗
💗
*/
#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;
}