結果

問題 No.2623 Room Allocation
ユーザー 👑 KA37RIKA37RI
提出日時 2024-02-10 00:28:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 82,784 KB
実行使用メモリ 145,900 KB
最終ジャッジ日時 2024-09-28 16:44:45
合計ジャッジ時間 7,773 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x, y = [int(z) for z in input().split()]
pc = [[z for z in input().split()] for _ in range(n)]
rm = x + y
need = [[0, 0] for _ in range(rm)]

for i in range(n):
	pi, ci = pc[i]
	if ci == "A":
		need[i%rm][0] += int(pi)
	else:
		need[i%rm][1] += int(pi)
		
need.sort(key=lambda a: a[1] - a[0])
ans = 0

for i in range(x):
	ans += need[i][0]
for i in range(y):
	ans += need[~i][1]
	
print(ans)
0