結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2022-08-21 15:29:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 454 ms / 2,000 ms |
| コード長 | 917 bytes |
| コンパイル時間 | 231 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 97,220 KB |
| 最終ジャッジ日時 | 2024-11-16 02:01:22 |
| 合計ジャッジ時間 | 4,365 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
import sys
readline = sys.stdin.readline
N, K = map(int, readline().split())
D = [[10 ** 18, 0]]
for i in range(K):
A, c = readline().split()
if c == "R":
n = 0
elif c == "G":
n = 1
else:
n = 2
D.append([int(A), n])
D.sort(reverse=True)
color = [0] * 3
ans = []
hat = ["R", "G", "B"]
for i in range(N):
if max(color) == min(color):
ind = 0
else:
for j in range(3):
if color[j] == min(color):
ind = j
break
temp = [0] * 3
for j in range(3):
temp[j] = color[j]
temp[ind] += 1
if D[-1][0] != i + 1:
ans.append(hat[ind])
color[ind] += 1
else:
A, c = D[-1]
D.pop()
if temp[c] == max(temp):
ans.append(hat[ind])
color[ind] += 1
else:
ans.append(hat[c])
color[c] += 1
print(*ans, sep="")
rlangevin