結果

問題 No.2623 Room Allocation
ユーザー PNJ
提出日時 2024-02-09 21:53:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 80,408 KB
最終ジャッジ日時 2024-09-28 15:08:51
合計ジャッジ時間 4,741 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def Map():
  return list(map(int,input().split()))

N,X,Y = Map()
Z = X + Y
C = [0 for i in range(N)]
ans = 0
for i in range(N):
  j = i % Z
  P,c = map(str,input().split())
  P = int(P)
  if c == 'A':
    C[j] += P
  else:
    C[j] -= P
    ans += P
C.sort()
if Z <= N:
  for i in range(X):
    ans += C.pop()
else:
  y = N
  x = 0
  while y > Y:
    ans += C.pop()
    y -= 1
    x += 1
  while x < X and len(C):
    if C[-1] > 0:
      ans += C.pop()
      y -= 1
      x += 1
    else:
      break
print(ans)
0