結果

問題 No.1328 alligachi-problem
ユーザー KudeKude
提出日時 2020-12-25 01:42:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 612 ms / 2,000 ms
コード長 898 bytes
コンパイル時間 1,233 ms
コンパイル使用メモリ 81,580 KB
実行使用メモリ 138,540 KB
最終ジャッジ日時 2023-10-21 16:08:13
合計ジャッジ時間 15,520 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,464 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 78 ms
73,584 KB
testcase_05 AC 87 ms
76,500 KB
testcase_06 AC 71 ms
70,892 KB
testcase_07 AC 88 ms
76,716 KB
testcase_08 AC 51 ms
61,096 KB
testcase_09 AC 593 ms
135,084 KB
testcase_10 AC 453 ms
114,928 KB
testcase_11 AC 582 ms
138,012 KB
testcase_12 AC 583 ms
138,180 KB
testcase_13 AC 588 ms
138,244 KB
testcase_14 AC 600 ms
135,276 KB
testcase_15 AC 470 ms
114,964 KB
testcase_16 AC 603 ms
133,500 KB
testcase_17 AC 590 ms
138,276 KB
testcase_18 AC 600 ms
135,348 KB
testcase_19 AC 612 ms
134,028 KB
testcase_20 AC 595 ms
138,436 KB
testcase_21 AC 597 ms
138,540 KB
testcase_22 AC 592 ms
138,276 KB
testcase_23 AC 457 ms
114,988 KB
testcase_24 AC 502 ms
129,024 KB
testcase_25 AC 548 ms
129,032 KB
testcase_26 AC 397 ms
120,644 KB
testcase_27 AC 392 ms
120,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
rs = []
bs = []
for i in range(1, n + 1):
    c, x, y = input().split()
    y = int(y)
    if x == 'R':
        rs.append((i, c, y))
    else:
        bs.append((i, c, y))
rs.sort(key=lambda p: 2 * p[2] + (p[1] == 'R'))
bs.sort(key=lambda p: 2 * p[2] + (p[1] == 'B'))
ans = []
rcnt = bcnt = 0
j = 0
for i, c, y in rs:
    while j < len(bs) and bcnt == bs[j][2] and not rcnt + (bs[j][1] == 'R') > y:
        ans.append(bs[j][0])
        if bs[j][1] == 'R':
            rcnt += 1
        else:
            bcnt += 1
        j += 1
    if rcnt != y:
        print('No')
        exit()
    ans.append(i)
    if c == 'R':
        rcnt += 1
    else:
        bcnt += 1
while j < len(bs) and bcnt == bs[j][2]:
    ans.append(bs[j][0])
    if bs[j][1] == 'R':
        rcnt += 1
    else:
        bcnt += 1
    j += 1
if not j == len(bs):
    print('No')
    exit()
print('Yes')
print(*ans)
0