結果

問題 No.2042 RGB Caps
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-08-19 22:04:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,052 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 99,476 KB
最終ジャッジ日時 2024-04-17 00:46:30
合計ジャッジ時間 6,200 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,840 KB
testcase_01 AC 42 ms
52,224 KB
testcase_02 AC 41 ms
51,712 KB
testcase_03 AC 46 ms
51,840 KB
testcase_04 AC 42 ms
52,096 KB
testcase_05 AC 41 ms
52,096 KB
testcase_06 AC 96 ms
84,992 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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):
    if now < k and AC[now][0] == i:
        # print(i)
        c = AC[now][1]
        
        now += 1
        ind = l.index(c)
        # print(c,ind,RGB)
        if max(RGB) == RGB[ind]:
            if i%3 == 1:
                RGB[ind] += 1
                ans.append(ind)
            else:
                m = max(RGB)
                for j in range(3):
                    if RGB[j] != m:
                        RGB[j] += 1
                        ans.append(j)
                        break
        else:
            RGB[ind] += 1
            ans.append(j)
    else:
        if i%3 == 1:
            RGB[0] += 1
            ans.append(0)
        else:
            m = max(RGB)
            for j in range(3):
                if RGB[j] != m:
                    RGB[j] += 1
                    ans.append(j)

ans = [l[i] for i in ans]
print("".join(ans))
0