結果

問題 No.2623 Room Allocation
ユーザー poeMoonpoeMoon
提出日時 2024-02-11 15:27:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 480 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 124,972 KB
最終ジャッジ日時 2024-02-11 15:27:32
合計ジャッジ時間 7,049 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 202 ms
87,056 KB
testcase_07 AC 198 ms
87,056 KB
testcase_08 AC 195 ms
86,672 KB
testcase_09 AC 205 ms
87,056 KB
testcase_10 AC 168 ms
120,236 KB
testcase_11 AC 143 ms
120,236 KB
testcase_12 AC 89 ms
94,096 KB
testcase_13 AC 89 ms
94,096 KB
testcase_14 AC 271 ms
124,972 KB
testcase_15 AC 153 ms
75,744 KB
testcase_16 AC 86 ms
75,744 KB
testcase_17 AC 60 ms
68,704 KB
testcase_18 AC 152 ms
75,744 KB
testcase_19 AC 151 ms
75,744 KB
testcase_20 AC 150 ms
75,744 KB
testcase_21 AC 154 ms
75,744 KB
testcase_22 AC 130 ms
75,744 KB
testcase_23 AC 103 ms
75,744 KB
testcase_24 AC 153 ms
75,744 KB
testcase_25 AC 138 ms
75,744 KB
testcase_26 AC 71 ms
75,744 KB
testcase_27 AC 463 ms
104,860 KB
testcase_28 AC 233 ms
103,424 KB
testcase_29 AC 159 ms
95,272 KB
testcase_30 AC 480 ms
101,420 KB
testcase_31 AC 99 ms
82,492 KB
testcase_32 AC 150 ms
102,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, X, Y = map(int, input().split())
r = X + Y
g = [[0, 0] for _ in range(r)]
m = ["A", "B"]
for i in range(N):
    P, c = input().split()
    P = int(P)
    g[i % r][m.index(c)] += P
g.sort(key=lambda gi: -abs(gi[0] - gi[1]))
ans = 0
for i in range(r):
    A, B = g[i][0], g[i][1]
    if A >= B:
        if X > 0:
            X -= 1
            ans += A
        else:
            Y -= 1
            ans += B
    else:
        if Y > 0:
            Y -= 1
            ans += B
        else:
            X -= 1
            ans += A
print(ans)
#print(*g)
0