結果
問題 | No.1328 alligachi-problem |
ユーザー | titia |
提出日時 | 2020-12-25 03:07:31 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 1,444 ms / 2,000 ms |
コード長 | 1,528 bytes |
コンパイル時間 | 84 ms |
コンパイル使用メモリ | 11,952 KB |
実行使用メモリ | 79,744 KB |
最終ジャッジ日時 | 2023-10-21 16:21:10 |
合計ジャッジ時間 | 30,213 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
10,252 KB |
testcase_01 | AC | 31 ms
10,252 KB |
testcase_02 | AC | 31 ms
10,252 KB |
testcase_03 | AC | 30 ms
10,252 KB |
testcase_04 | AC | 39 ms
10,952 KB |
testcase_05 | AC | 40 ms
11,000 KB |
testcase_06 | AC | 38 ms
10,952 KB |
testcase_07 | AC | 42 ms
11,128 KB |
testcase_08 | AC | 34 ms
10,476 KB |
testcase_09 | AC | 1,428 ms
79,744 KB |
testcase_10 | AC | 1,090 ms
77,568 KB |
testcase_11 | AC | 1,400 ms
79,744 KB |
testcase_12 | AC | 1,380 ms
79,744 KB |
testcase_13 | AC | 1,405 ms
79,744 KB |
testcase_14 | AC | 1,422 ms
79,744 KB |
testcase_15 | AC | 1,073 ms
77,568 KB |
testcase_16 | AC | 1,388 ms
79,744 KB |
testcase_17 | AC | 1,398 ms
79,744 KB |
testcase_18 | AC | 1,392 ms
79,744 KB |
testcase_19 | AC | 1,404 ms
79,744 KB |
testcase_20 | AC | 1,411 ms
79,744 KB |
testcase_21 | AC | 1,444 ms
79,744 KB |
testcase_22 | AC | 1,435 ms
79,744 KB |
testcase_23 | AC | 1,103 ms
77,500 KB |
testcase_24 | AC | 1,229 ms
77,504 KB |
testcase_25 | AC | 1,252 ms
77,504 KB |
testcase_26 | AC | 1,157 ms
76,728 KB |
testcase_27 | AC | 1,167 ms
76,632 KB |
ソースコード
from operator import itemgetter N=int(input()) S=[input().split() for i in range(N)] for i in range(N): S[i][2]=int(S[i][2]) SB=[] SR=[] for i in range(N): if S[i][1]=="B": SB.append(S[i]+[i+1]) else: SR.append(S[i]+[i+1]) SB.sort(key=itemgetter(0),reverse=True) SB.sort(key=itemgetter(2)) SR.sort(key=itemgetter(0)) SR.sort(key=itemgetter(2)) #print(SB) #print(SR) SB.reverse() SR.reverse() B=0 R=0 ANS=[] while SB or SR: if SB and SR: if SB[-1][2]==B and SB[-1][0]=="B": x=SB.pop() ANS.append(x[3]) B+=1 continue if SR[-1][2]==R and SR[-1][0]=="R": x=SR.pop() ANS.append(x[3]) R+=1 continue if SB[-1][2]==B and SB[-1][0]=="R" and SR[-1][2]!=R: x=SB.pop() ANS.append(x[3]) R+=1 continue if SR[-1][2]==R and SR[-1][0]=="B" and SB[-1][2]!=B: x=SR.pop() ANS.append(x[3]) B+=1 continue else: if SB and SB[-1][2]==B: x=SB.pop() ANS.append(x[3]) if x[0]=="B": B+=1 else: R+=1 continue if SR and SR[-1][2]==R: x=SR.pop() ANS.append(x[3]) if x[0]=="B": B+=1 else: R+=1 continue print("No") break else: print("Yes") print(*ANS)