結果
問題 | No.2042 RGB Caps |
ユーザー | vwxyz |
提出日時 | 2023-07-15 20:51:47 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 296 ms / 2,000 ms |
コード長 | 1,171 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 11,904 KB |
実行使用メモリ | 15,252 KB |
最終ジャッジ日時 | 2023-10-17 06:57:52 |
合計ジャッジ時間 | 5,192 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
11,236 KB |
testcase_01 | AC | 36 ms
11,236 KB |
testcase_02 | AC | 37 ms
11,236 KB |
testcase_03 | AC | 37 ms
11,236 KB |
testcase_04 | AC | 37 ms
11,236 KB |
testcase_05 | AC | 36 ms
11,236 KB |
testcase_06 | AC | 206 ms
15,252 KB |
testcase_07 | AC | 126 ms
12,888 KB |
testcase_08 | AC | 212 ms
14,248 KB |
testcase_09 | AC | 68 ms
11,836 KB |
testcase_10 | AC | 278 ms
15,148 KB |
testcase_11 | AC | 88 ms
12,476 KB |
testcase_12 | AC | 296 ms
15,252 KB |
testcase_13 | AC | 296 ms
15,252 KB |
testcase_14 | AC | 291 ms
15,252 KB |
testcase_15 | AC | 37 ms
11,236 KB |
testcase_16 | AC | 119 ms
12,728 KB |
testcase_17 | AC | 61 ms
11,736 KB |
ソースコード
import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write N,K=map(int,readline().split()) C=[None]*N for k in range(K): A,c=readline().split() A=int(A)-1 C[A]=c ans_lst=[None]*N cnt={s:0 for s in "RGB"} for n in range(N): if C[n]!=None and (max(cnt.values())>cnt[C[n]] or min(cnt.values())==cnt[C[n]]): cnt[C[n]]+=1 ans_lst[n]=C[n] else: for s in "RGB": if min(cnt.values())==cnt[s]: cnt[s]+=1 ans_lst[n]=s break print(*ans_lst,sep="")