結果

問題 No.2623 Room Allocation
ユーザー PNJPNJ
提出日時 2024-02-09 21:54:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 79,768 KB
最終ジャッジ日時 2024-02-09 21:55:07
合計ジャッジ時間 4,566 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 41 ms
53,460 KB
testcase_03 AC 32 ms
53,460 KB
testcase_04 AC 31 ms
53,460 KB
testcase_05 AC 31 ms
53,460 KB
testcase_06 AC 148 ms
77,044 KB
testcase_07 AC 147 ms
77,300 KB
testcase_08 AC 145 ms
77,300 KB
testcase_09 AC 148 ms
77,300 KB
testcase_10 AC 32 ms
53,460 KB
testcase_11 AC 32 ms
53,460 KB
testcase_12 AC 32 ms
53,460 KB
testcase_13 AC 34 ms
53,460 KB
testcase_14 AC 157 ms
79,004 KB
testcase_15 AC 157 ms
75,880 KB
testcase_16 AC 81 ms
75,880 KB
testcase_17 AC 55 ms
68,812 KB
testcase_18 AC 136 ms
75,896 KB
testcase_19 AC 129 ms
75,896 KB
testcase_20 AC 133 ms
75,892 KB
testcase_21 AC 141 ms
75,880 KB
testcase_22 AC 115 ms
75,896 KB
testcase_23 AC 95 ms
75,892 KB
testcase_24 AC 138 ms
75,896 KB
testcase_25 AC 140 ms
75,880 KB
testcase_26 AC 64 ms
75,892 KB
testcase_27 AC 172 ms
79,644 KB
testcase_28 AC 101 ms
76,968 KB
testcase_29 AC 79 ms
76,164 KB
testcase_30 AC 177 ms
79,768 KB
testcase_31 AC 67 ms
76,032 KB
testcase_32 AC 64 ms
76,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Map():
  return list(map(int,input().split()))

N,X,Y = Map()
Z = X + Y
C = [0 for i in range(min(Z,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()
y = len(C)
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