結果

問題 No.2042 RGB Caps
ユーザー first_vilfirst_vil
提出日時 2022-08-19 22:01:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 83,768 KB
最終ジャッジ日時 2024-04-27 20:33:44
合計ジャッジ時間 2,657 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,800 KB
testcase_01 AC 36 ms
53,616 KB
testcase_02 AC 35 ms
52,956 KB
testcase_03 AC 35 ms
52,700 KB
testcase_04 AC 35 ms
53,076 KB
testcase_05 AC 36 ms
53,024 KB
testcase_06 AC 69 ms
83,252 KB
testcase_07 AC 70 ms
78,556 KB
testcase_08 AC 82 ms
81,228 KB
testcase_09 AC 63 ms
76,576 KB
testcase_10 AC 99 ms
82,588 KB
testcase_11 AC 61 ms
78,088 KB
testcase_12 AC 99 ms
83,668 KB
testcase_13 AC 94 ms
83,768 KB
testcase_14 AC 97 ms
82,884 KB
testcase_15 AC 35 ms
53,560 KB
testcase_16 AC 70 ms
77,900 KB
testcase_17 AC 61 ms
76,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
mod = int(1e9 + 7)
# mod = 998244353

n, k = mi()
t = [-1] * n
rgb = "RGB"
for i in range(k):
    a, c = input().split()
    a = int1(a)
    t[a] = rgb.index(c)
ans = []
cnt = [0, 0, 0]
for i in range(n):
    if t[i] != -1 and cnt[t[i]] == min(cnt):
        ans.append(rgb[t[i]])
        cnt[t[i]] += 1
    else:
        j = cnt.index(min(cnt))
        ans.append(rgb[j])
        cnt[j] += 1
print("".join(ans))
0