結果

問題 No.2623 Room Allocation
ユーザー shobonvipshobonvip
提出日時 2024-02-09 21:36:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,581 bytes
コンパイル時間 4,452 ms
コンパイル使用メモリ 269,296 KB
実行使用メモリ 20,124 KB
最終ジャッジ日時 2024-02-09 21:36:33
合計ジャッジ時間 7,548 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 1 ms
6,676 KB
testcase_06 AC 55 ms
8,904 KB
testcase_07 AC 54 ms
8,904 KB
testcase_08 AC 54 ms
8,904 KB
testcase_09 AC 53 ms
8,904 KB
testcase_10 AC 24 ms
18,652 KB
testcase_11 AC 26 ms
18,652 KB
testcase_12 AC 18 ms
12,292 KB
testcase_13 AC 14 ms
12,292 KB
testcase_14 AC 149 ms
20,124 KB
testcase_15 AC 96 ms
6,676 KB
testcase_16 AC 24 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 95 ms
6,676 KB
testcase_19 AC 89 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 41 ms
6,676 KB
testcase_24 AC 95 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
19,036 KB
testcase_28 AC 57 ms
11,864 KB
testcase_29 AC 35 ms
13,020 KB
testcase_30 AC 125 ms
13,340 KB
testcase_31 AC 13 ms
6,728 KB
testcase_32 AC 45 ms
16,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	int n, x, y; cin >> n >> x >> y;
	vector<char> c(n);
	vector<ll> p(n);
	rep(i,0,n) cin >> p[i] >> c[i];

	vector<ll> rui_a(x+y), rui_b(x+y);

	rep(i,0,n){
		if (c[i] == 'A'){
			rui_a[i%(x+y)] += p[i];
		}else{
			rui_b[i%(x+y)] += p[i];
		}
	}

	vector<pair<ll,ll>> pr;
	rep(i,0,x+y){
		pr.push_back(pair(rui_a[i] - rui_b[i], i));
	}
	sort(pr.begin(), pr.end());
	reverse(pr.begin(), pr.end());
	
	ll ans = 0;
	rep(i,0,x){
		ans += rui_a[pr[i].second];
	}
	rep(i,0,y){
		ans += rui_b[pr[i+x].second];
	}
	cout << ans << '\n';
}

0