結果
問題 | No.2623 Room Allocation |
ユーザー |
|
提出日時 | 2024-02-09 22:34:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 264 ms / 2,000 ms |
コード長 | 549 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 82,440 KB |
実行使用メモリ | 113,900 KB |
最終ジャッジ日時 | 2024-09-28 15:46:46 |
合計ジャッジ時間 | 6,043 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
N,X,Y=map(int,input().split())client=[]for i in range(N):P,c=input().split()P=int(P)client.append((P,c))af=[]bf=[]a=0b=0ans=0for i in range(X+Y):cnt=[0,0]for j in range(i,N,X+Y):P,c=client[j]if c=="A":cnt[0]+=Pelse:cnt[1]+=Pif max(cnt[0],cnt[1])==0:continueif cnt[0]>=cnt[1]:a+=1ans+=cnt[0]af.append(abs(cnt[0]-cnt[1]))else:b+=1ans+=cnt[1]bf.append(abs(cnt[0]-cnt[1]))af.sort(reverse=True)bf.sort(reverse=True)while len(af)>X:ans-=af.pop()while len(bf)>Y:ans-=bf.pop()print(ans)