結果
問題 |
No.2042 RGB Caps
|
ユーザー |
![]() |
提出日時 | 2023-08-10 18:13:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 930 ms / 2,000 ms |
コード長 | 1,139 bytes |
コンパイル時間 | 345 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 109,172 KB |
最終ジャッジ日時 | 2024-11-17 02:55:47 |
合計ジャッジ時間 | 8,214 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
# とにかくできるだけイーブンにR, G, Bを増やしていく # 証言は順番昇順でソート # 証言の色が足らなければ増やす、そうでなければイーブンにする # 同順位でいいので不可能はないはず N, K = map(int, input().split()) testimony = {} for i in range(K): a, c = map(str, input().split()) if c == 'R': testimony[int(a)] = 0 elif c == 'G': testimony[int(a)] = 1 elif c == 'B': testimony[int(a)] = 2 RGB = [0, 0, 0] ans = '' string = 'RGB' for i in range(N): smallest_num = min(RGB) if i+1 in testimony: if RGB[testimony[i+1]] == smallest_num: RGB[testimony[i+1]] += 1 ans += string[testimony[i+1]] else: for j in range(3): if RGB[j] == smallest_num: RGB[j] += 1 ans += string[j] break else: for j in range(3): if RGB[j] == smallest_num: RGB[j] += 1 ans += string[j] break #print('i', i, 'RGB', RGB, 'ans', ans) print(ans)