結果

問題 No.2623 Room Allocation
ユーザー hirayuu_ychirayuu_yc
提出日時 2024-02-09 22:34:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 113,524 KB
最終ジャッジ日時 2024-02-09 22:34:31
合計ジャッジ時間 5,895 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 33 ms
53,460 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 AC 34 ms
53,460 KB
testcase_05 AC 32 ms
53,460 KB
testcase_06 AC 226 ms
103,668 KB
testcase_07 AC 195 ms
103,664 KB
testcase_08 AC 195 ms
104,044 KB
testcase_09 AC 196 ms
103,660 KB
testcase_10 AC 47 ms
75,136 KB
testcase_11 AC 45 ms
75,136 KB
testcase_12 AC 43 ms
75,136 KB
testcase_13 AC 44 ms
75,136 KB
testcase_14 AC 216 ms
112,764 KB
testcase_15 AC 209 ms
103,468 KB
testcase_16 AC 95 ms
82,272 KB
testcase_17 AC 56 ms
70,940 KB
testcase_18 AC 208 ms
103,476 KB
testcase_19 AC 204 ms
103,216 KB
testcase_20 AC 228 ms
103,472 KB
testcase_21 AC 206 ms
103,476 KB
testcase_22 AC 165 ms
94,872 KB
testcase_23 AC 117 ms
86,624 KB
testcase_24 AC 206 ms
103,468 KB
testcase_25 AC 203 ms
97,460 KB
testcase_26 AC 71 ms
77,152 KB
testcase_27 AC 236 ms
112,500 KB
testcase_28 AC 129 ms
87,648 KB
testcase_29 AC 100 ms
81,120 KB
testcase_30 AC 236 ms
113,524 KB
testcase_31 AC 85 ms
77,280 KB
testcase_32 AC 90 ms
77,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,X,Y=map(int,input().split())
client=[]
for i in range(N):
	P,c=input().split()
	P=int(P)
	client.append((P,c))
af=[]
bf=[]
a=0
b=0
ans=0
for i in range(X+Y):
	cnt=[0,0]
	for j in range(i,N,X+Y):
		P,c=client[j]
		if c=="A":
			cnt[0]+=P
		else:
			cnt[1]+=P
	if max(cnt[0],cnt[1])==0:
		continue
	if cnt[0]>=cnt[1]:
		a+=1
		ans+=cnt[0]
		af.append(abs(cnt[0]-cnt[1]))
	else:
		b+=1
		ans+=cnt[1]
		bf.append(abs(cnt[0]-cnt[1]))
af.sort(reverse=True)
bf.sort(reverse=True)
while len(af)>X:
	ans-=af.pop()
while len(bf)>Y:
	ans-=bf.pop()
print(ans)
0