結果
問題 | No.1328 alligachi-problem |
ユーザー |
![]() |
提出日時 | 2020-12-25 01:42:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 616 ms / 2,000 ms |
コード長 | 898 bytes |
コンパイル時間 | 590 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 138,976 KB |
最終ジャッジ日時 | 2024-09-21 17:23:34 |
合計ジャッジ時間 | 16,140 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
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)