結果

問題 No.2623 Room Allocation
ユーザー nikoro256nikoro256
提出日時 2024-02-09 21:55:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,632 ms / 2,000 ms
コード長 973 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 214,136 KB
最終ジャッジ日時 2024-02-09 21:55:31
合計ジャッジ時間 9,901 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
53,460 KB
testcase_01 AC 32 ms
53,460 KB
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 32 ms
53,460 KB
testcase_06 AC 353 ms
146,268 KB
testcase_07 AC 354 ms
146,268 KB
testcase_08 AC 362 ms
146,268 KB
testcase_09 AC 388 ms
146,268 KB
testcase_10 AC 80 ms
98,728 KB
testcase_11 AC 77 ms
98,728 KB
testcase_12 AC 69 ms
95,244 KB
testcase_13 AC 71 ms
95,244 KB
testcase_14 AC 614 ms
211,956 KB
testcase_15 AC 192 ms
117,476 KB
testcase_16 AC 82 ms
83,624 KB
testcase_17 AC 46 ms
66,632 KB
testcase_18 AC 187 ms
117,472 KB
testcase_19 AC 176 ms
115,296 KB
testcase_20 AC 186 ms
116,836 KB
testcase_21 AC 213 ms
117,472 KB
testcase_22 AC 159 ms
105,952 KB
testcase_23 AC 110 ms
92,456 KB
testcase_24 AC 188 ms
117,472 KB
testcase_25 AC 162 ms
108,256 KB
testcase_26 AC 63 ms
78,120 KB
testcase_27 AC 1,632 ms
214,136 KB
testcase_28 AC 517 ms
125,624 KB
testcase_29 AC 248 ms
108,328 KB
testcase_30 AC 1,559 ms
191,176 KB
testcase_31 AC 124 ms
82,472 KB
testcase_32 AC 145 ms
106,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
N,X,Y=map(int,input().split())
dat=[]
for _ in range(N):
    dat.append(list(map(str,input().split())))
point=[[0,0] for _ in range(X+Y)]
for i in range(N):
    p,c=dat[i]
    p=int(p)
    if c=='A':
        point[i%(X+Y)][0]+=p
    else:
        point[i%(X+Y)][1]+=p
lis=[]
for i in range(X+Y):
    if point[i]!=[0,0]:
        lis.append([-point[i][0]+point[i][1],i,'A'])
        lis.append([-point[i][1]+point[i][0],i,'B'])
lis.sort()
ans=['']*(X+Y)
countA,countB=X,Y
for sub,i,c in lis:
    if ans[i]=='':
        if c=='A':
            if countA>0:
                ans[i]='A'
                countA-=1
            else:
                ans[i]='B'
                countB-=1
        if c=='B':
            if countB>0:
                ans[i]='B'
                countB-=1
            else:
                ans[i]='A'
                countA-=1
fa=0
for i in range(N):
    if ans[i%(X+Y)]==dat[i][1]:
        fa+=int(dat[i][0])
print(fa)
0