結果

問題 No.2623 Room Allocation
ユーザー ゼット
提出日時 2024-02-09 21:53:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 90,868 KB
最終ジャッジ日時 2024-09-28 15:09:18
合計ジャッジ時間 4,933 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

N,x,y=map(int,input().split())
v1=[0]*(x+y)
v2=[0]*(x+y)
L1=[]
L2=[]
for i in range(N):
  p,c=input().split()
  p=int(p)
  if c=='A':
    L1.append(p)
    v1[i%(x+y)]+=p
  else:
    L2.append(p)
    v2[i%(x+y)]+=p
if N>x+y:
  L=[]
  for i in range(x+y):
    L.append((v1[i]-v2[i],v1[i]))
  result=0
  L.sort(reverse=True)
  for i in range(x+y):
    z,w=L[i][:]
    if i<x:
      result+=w
    else:
      result+=w-z
  print(result)
else:
  L1.sort(reverse=True)
  L2.sort(reverse=True)
  result=0
  for i in range(len(L1)):
    if i>=x:
      break
    result+=L1[i]
  for i in range(len(L2)):
    if i>=y:
      break
    result+=L2[i]
  print(result)
0