結果

問題 No.2623 Room Allocation
ユーザー 👑 H20H20
提出日時 2024-02-09 22:36:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 180,796 KB
最終ジャッジ日時 2024-02-09 22:36:08
合計ジャッジ時間 5,979 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 32 ms
53,460 KB
testcase_02 AC 32 ms
53,460 KB
testcase_03 AC 32 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 32 ms
53,460 KB
testcase_06 AC 197 ms
116,456 KB
testcase_07 AC 223 ms
116,840 KB
testcase_08 AC 196 ms
116,840 KB
testcase_09 AC 194 ms
116,840 KB
testcase_10 AC 100 ms
127,656 KB
testcase_11 AC 102 ms
127,656 KB
testcase_12 AC 83 ms
109,200 KB
testcase_13 AC 84 ms
109,072 KB
testcase_14 AC 306 ms
180,796 KB
testcase_15 AC 182 ms
107,752 KB
testcase_16 AC 89 ms
84,292 KB
testcase_17 AC 52 ms
68,696 KB
testcase_18 AC 184 ms
107,752 KB
testcase_19 AC 181 ms
107,652 KB
testcase_20 AC 197 ms
107,724 KB
testcase_21 AC 194 ms
107,752 KB
testcase_22 AC 178 ms
101,728 KB
testcase_23 AC 111 ms
90,080 KB
testcase_24 AC 183 ms
107,752 KB
testcase_25 AC 160 ms
101,820 KB
testcase_26 AC 66 ms
78,280 KB
testcase_27 AC 289 ms
164,968 KB
testcase_28 AC 150 ms
115,064 KB
testcase_29 AC 150 ms
109,132 KB
testcase_30 AC 280 ms
154,856 KB
testcase_31 AC 84 ms
85,576 KB
testcase_32 AC 131 ms
125,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,X,Y = map(int, input().split())
PC = [input().split() for _ in range(N)]
L = [[0]*2 for _ in range(X+Y)]
for i,pc in enumerate(PC):
    p,c=int(pc[0]),pc[1]
    L[i%(X+Y)][c=='B']+=p
ans = 0
DIFF = []
for a,b in L:
    DIFF.append(a-b)
    ans+=min(a,b)
DIFF.sort(reverse=True)
for a in DIFF[:X]:
    ans+=max(0,a)
for b in DIFF[X:]:
    ans+=max(0,-b)
print(ans)
0