結果

問題 No.2623 Room Allocation
ユーザー ゼットゼット
提出日時 2024-02-09 21:53:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 90,592 KB
最終ジャッジ日時 2024-02-09 21:53:26
合計ジャッジ時間 5,447 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 40 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 193 ms
90,572 KB
testcase_07 AC 218 ms
90,592 KB
testcase_08 AC 196 ms
90,572 KB
testcase_09 AC 194 ms
90,592 KB
testcase_10 AC 41 ms
59,704 KB
testcase_11 AC 39 ms
59,704 KB
testcase_12 AC 38 ms
56,660 KB
testcase_13 AC 38 ms
56,660 KB
testcase_14 AC 176 ms
89,552 KB
testcase_15 AC 162 ms
82,676 KB
testcase_16 AC 88 ms
76,920 KB
testcase_17 AC 61 ms
68,712 KB
testcase_18 AC 174 ms
82,656 KB
testcase_19 AC 157 ms
82,536 KB
testcase_20 AC 160 ms
82,664 KB
testcase_21 AC 164 ms
82,680 KB
testcase_22 AC 140 ms
80,764 KB
testcase_23 AC 107 ms
78,460 KB
testcase_24 AC 163 ms
82,660 KB
testcase_25 AC 175 ms
80,760 KB
testcase_26 AC 76 ms
75,772 KB
testcase_27 AC 205 ms
88,060 KB
testcase_28 AC 119 ms
81,808 KB
testcase_29 AC 88 ms
79,332 KB
testcase_30 AC 207 ms
87,524 KB
testcase_31 AC 74 ms
76,836 KB
testcase_32 AC 79 ms
80,200 KB
権限があれば一括ダウンロードができます

ソースコード

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