結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
taiga0629kyopro
|
| 提出日時 | 2022-08-19 21:40:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 354 ms / 2,000 ms |
| コード長 | 910 bytes |
| コンパイル時間 | 177 ms |
| コンパイル使用メモリ | 82,000 KB |
| 実行使用メモリ | 89,036 KB |
| 最終ジャッジ日時 | 2024-11-16 01:54:14 |
| 合計ジャッジ時間 | 3,761 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
n,k=map(int,input().split())
ans=[-1]*(n+1)
que=[]
for i in range(k):
a,k=input().split()
a=int(a)
if k=="R":k=0
elif k=="G":k=1
else:k=2
que.append((a,k))
que.sort()
cnt=[0,0,0]
now=1
for a,k in que:
while now<=3*(a//3):
for j in range(3):
if min(cnt)==cnt[j]:
ans[now]=j
cnt[j]+=1
now+=1
break
if a%3==0:continue
elif a%3==1:
ans[a]=k
cnt[k]+=1
now+=1
else:
if now==a-1:
ans[now]=k
cnt[k]+=1
now+=1
else:
if ans[a-1]==k:continue
else:
ans[now]=k
cnt[k]+=1
now+=1
res=[]
for i in range(1,n+1):
if ans[i]==0:
res.append("R")
elif ans[i]==1:
res.append("G")
else:
res.append("B")
print("".join(res))
taiga0629kyopro