結果

問題 No.2042 RGB Caps
ユーザー asumo0729asumo0729
提出日時 2022-08-19 22:26:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,249 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 82,844 KB
最終ジャッジ日時 2024-04-17 01:06:11
合計ジャッジ時間 4,914 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
61,184 KB
testcase_01 WA -
testcase_02 AC 63 ms
60,800 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter, le
from collections import defaultdict, deque
import heapq
from heapq import heapify, heappop, _heapify_max, heappush
from bisect import bisect_left, bisect_right
import math
import itertools
import copy

stdin=sys.stdin
#sys.setrecursionlimit(10 ** 7)
## import pypyjit
## pypyjit.set_param('max_unroll_recursion=-1')

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
Yp=lambda:print('Yes')
Np=lambda:print('No')
inf = 1 << 60
mod = 10 ** 9 + 7
mod = 998244353
eps = 1e-9
sortkey1 = itemgetter(0)
sortkey2 = lambda x: (x[0], x[1])



###############################################################

N, K = lp()
A = []
RGB = 'RGB'
for _ in range(K):
    a, c = input().split()
    a = int(a) - 1;c = RGB.index(c)
    A.append((a,c))
A.sort()
rgb = [0 for _ in range(3)]
idx = -1
ans = []
for a, c in A:
    need = (a + 1) // 3 + 1
    if a - idx + rgb[c] < need:
        print(-1)
        exit()
    for _ in range(need - rgb[c]):
        ans.append(c)
        idx += 1
    rgb[c] = need
answer = []
for x in ans:
    answer.append(RGB[x])
l = N - len(answer)
for _ in range(l):
    answer.append('B')
print(''.join(answer))
0