結果
| 問題 | 
                            No.2623 Room Allocation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             PNJ
                         | 
                    
| 提出日時 | 2024-02-09 21:30:56 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 761 bytes | 
| コンパイル時間 | 315 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 81,536 KB | 
| 最終ジャッジ日時 | 2024-09-28 13:57:15 | 
| 合計ジャッジ時間 | 5,336 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 17 WA * 13 | 
ソースコード
from collections import deque
def Map():
  return list(map(int,input().split()))
N,X,Y = Map()
x = 0
y = 0
XX = deque()
YY = deque()
ans = 0
for i in range(N):
  P,c = map(str,input().split())
  P = int(P)
  cc = 1
  if c == 'A':
    if x < X:
      XX.append(i)
      x += 1
      ans += P
    elif y < Y:
      YY.append(i)
      y += 1
    else:
      if XX[0] < YY[0]:
        XX.popleft()
        XX.append(i)
        ans += P
      else:
        YY.popleft()
        YY.append(i)
  else:
    if y < Y:
      YY.append(i)
      y += 1
      ans += P
    elif x < X:
      XX.append(i)
      x += 1
    else:
      if YY[0] < XX[0]:
        YY.popleft()
        YY.append(i)
        ans += P
      else:
        XX.popleft()
        XX.append(i)
print(ans)
            
            
            
        
            
PNJ