結果

問題 No.2623 Room Allocation
ユーザー lloyz
提出日時 2024-02-12 19:08:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 764 ms / 2,000 ms
コード長 439 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 148,028 KB
最終ジャッジ日時 2024-09-28 18:10:52
合計ジャッジ時間 7,269 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x, y = map(int, input().split())
xy = x + y
C = [[0, 0] for _ in range(xy)]
for i in range(n):
    p, c = input().split()
    p = int(p)
    if c == 'A':
        j = 0
    else:
        j = 1
    C[i % xy][j] += p
D = [(C[i][0] - C[i][1], i) for i in range(xy)]
D.sort(key=lambda x: (x[0], x[1]), reverse=True)
ans = 0
for i in range(xy):
    j = D[i][1]
    if i < x:
        ans += C[j][0]
    else:
        ans += C[j][1]
print(ans)
0