結果

問題 No.2042 RGB Caps
ユーザー とりゐとりゐ
提出日時 2022-08-19 22:06:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 93,220 KB
最終ジャッジ日時 2024-04-27 20:33:58
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,136 KB
testcase_01 AC 36 ms
52,148 KB
testcase_02 AC 34 ms
52,624 KB
testcase_03 AC 36 ms
52,072 KB
testcase_04 AC 35 ms
52,544 KB
testcase_05 AC 36 ms
52,372 KB
testcase_06 AC 86 ms
89,556 KB
testcase_07 AC 100 ms
82,224 KB
testcase_08 AC 139 ms
86,384 KB
testcase_09 AC 81 ms
77,240 KB
testcase_10 AC 161 ms
93,220 KB
testcase_11 AC 81 ms
79,140 KB
testcase_12 AC 161 ms
90,956 KB
testcase_13 AC 155 ms
90,680 KB
testcase_14 AC 163 ms
91,460 KB
testcase_15 AC 37 ms
52,948 KB
testcase_16 AC 99 ms
81,392 KB
testcase_17 AC 83 ms
77,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k=map(int,input().split())
a=[-1]*n
for i in range(k):
  ai,ci=input().split()
  a[int(ai)-1]=ci

d={'R':0,'G':1,'B':2}
color='RGB'

ans=[]
cnt=[0]*3
for i in range(n):
  if a[i]==-1:
    idx=cnt.index(min(cnt))
    ans.append(color[idx])
    cnt[idx]+=1
  else:
    c=a[i]
    if min(cnt)==cnt[d[c]]:
      ans.append(c)
      cnt[d[c]]+=1
    else:
      idx=cnt.index(min(cnt))
      ans.append(color[idx])
      cnt[idx]+=1

print(*ans,sep='')
0