結果

問題 No.2623 Room Allocation
ユーザー manjuuu_onsen
提出日時 2024-02-09 21:40:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 177,044 KB
実行使用メモリ 25,184 KB
最終ジャッジ日時 2024-09-28 14:55:26
合計ジャッジ時間 4,345 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;


int main()
{
	ll n,x,y;
	cin>>n>>x>>y;
	vector<vector<ll>> w(x+y,vector<ll>(2));
	for(ll i=0; i<n; i++) {
		ll p;
		char c;
		cin>>p>>c;
		w[i%(x+y)][c-'A'] += p;
	}

	sort(w.begin(), w.end(), [&](vector<ll>& x, vector<ll>&y){return x[0] - x[1] > y[0] - y[1];});
	ll ans = 0;
	for(ll i=0; i<x; i++) ans += w[i][0];
	for(ll j=x; j<x+y; j++) ans += w[j][1];
	cout << ans << endl;

}
0