結果

問題 No.2623 Room Allocation
ユーザー hato336
提出日時 2024-02-09 21:46:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 364 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 154,380 KB
最終ジャッジ日時 2024-09-28 15:00:57
合計ジャッジ時間 8,441 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
input = sys.stdin.readline
#n = int(input())
#alist = list(map(int,input().split()))
#alist = []
n,x,y = map(int,input().split())
ans = 0
alist = []
for i in range(n):
    p,c = input().split()
    p = int(p)
    alist.append((p,0) if c == 'A' else(p,1))
d = collections.deque()
dp = [[0,0] for i in range(x+y)]
for i in range(x+y):
    j = i
    while j < n:
        dp[i][alist[j][1]] += alist[j][0]
        j += x+y
h = []
ans = 0
for i in range(x+y):
    ans += dp[i][0]
    heapq.heappush(h,-(dp[i][1]-dp[i][0]))
for i in range(y):
    ans -= heapq.heappop(h)
print(ans)
0