結果

問題 No.2623 Room Allocation
ユーザー miya145592miya145592
提出日時 2024-02-10 00:44:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 826 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 210,204 KB
最終ジャッジ日時 2024-02-10 00:44:33
合計ジャッジ時間 7,529 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 32 ms
53,460 KB
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 33 ms
53,460 KB
testcase_04 AC 33 ms
53,460 KB
testcase_05 AC 33 ms
53,460 KB
testcase_06 AC 185 ms
131,356 KB
testcase_07 AC 189 ms
131,740 KB
testcase_08 AC 209 ms
131,740 KB
testcase_09 AC 184 ms
131,740 KB
testcase_10 AC 247 ms
172,996 KB
testcase_11 AC 243 ms
172,996 KB
testcase_12 AC 146 ms
124,072 KB
testcase_13 AC 172 ms
124,072 KB
testcase_14 AC 443 ms
210,204 KB
testcase_15 AC 133 ms
110,492 KB
testcase_16 AC 64 ms
81,532 KB
testcase_17 AC 39 ms
62,216 KB
testcase_18 AC 130 ms
110,492 KB
testcase_19 AC 131 ms
107,704 KB
testcase_20 AC 127 ms
107,776 KB
testcase_21 AC 140 ms
110,492 KB
testcase_22 AC 111 ms
99,092 KB
testcase_23 AC 102 ms
90,260 KB
testcase_24 AC 131 ms
110,492 KB
testcase_25 AC 119 ms
103,792 KB
testcase_26 AC 48 ms
70,460 KB
testcase_27 AC 826 ms
186,268 KB
testcase_28 AC 358 ms
140,972 KB
testcase_29 AC 241 ms
131,332 KB
testcase_30 AC 786 ms
174,236 KB
testcase_31 AC 103 ms
92,604 KB
testcase_32 AC 213 ms
144,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, X, Y = map(int, input().split())
PC = [input().split() for _ in range(N)]
S = X+Y
dp = [[0 for _ in range(2)] for _ in range(S)]
for i, pc in enumerate(PC):
    p, c = pc
    p=int(p)
    if c=="A":
        dp[i%S][0]+=p
    else:
        dp[i%S][1]+=p
for i in range(S):
    a, b = dp[i]
    dp[i] = [a, b, a-b, i]
dp.sort(key=lambda x:(x[2], x[0]))
ans = 0
for _ in range(X):
    a, b, sa, i = dp.pop()
    ans += a
for _ in range(Y):
    a, b, sa, i = dp.pop()
    ans += b
print(ans)
0