結果
問題 |
No.2042 RGB Caps
|
ユーザー |
|
提出日時 | 2022-08-19 22:14:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 551 ms / 2,000 ms |
コード長 | 995 bytes |
コンパイル時間 | 276 ms |
コンパイル使用メモリ | 82,784 KB |
実行使用メモリ | 100,964 KB |
最終ジャッジ日時 | 2024-11-16 01:57:06 |
合計ジャッジ時間 | 5,097 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
from cmath import inf n,k = map(int,input().split()) ans = [] RGB = [0]*3 AC = [] for i in range(k): a,c = input().split() a = int(a) AC.append([a,c]) AC.sort() l = "RGB" now = 0 for i in range(1,n+1): target = 0 ind = -1 if now < k and AC[now][0] == i: c = AC[now][1] ind = l.index(c) if max(RGB) == RGB[ind]: if RGB.count(max(RGB)) == 3: target = ind else: for j in range(3): if RGB[j] != max(RGB): target = j break else: target = ind now += 1 else: for j in range(3): if RGB[j] != max(RGB): target = j break ans.append(target) RGB[target] += 1 assert max(RGB)-min(RGB) <= 1 if ind != -1 and max(RGB) != RGB[ind]: print(-1) exit() ans = [l[i] for i in ans] print("".join(ans))