結果

問題 No.2042 RGB Caps
ユーザー gr1msl3y
提出日時 2022-08-25 23:16:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 78,212 KB
最終ジャッジ日時 2024-11-16 02:01:33
合計ジャッジ時間 2,711 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
A = [-1]*N
S = 'RGB'
for _ in range(K):
    a, b = input().split()
    A[int(a)-1] = S.index(b)

ans = [-1]*N
ct = [0]*3
for i in range(N):
    if A[i] >= 0 and ct[A[i]] == min(ct):
        ans[i] = A[i]
    else:
        ans[i] = ct.index(min(ct))
    ct[ans[i]] += 1

print(''.join(S[a] for a in ans))
0