0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ABC141 C - Attack Survival を解いた

Last updated at Posted at 2021-10-14

abc141_1.png
abc141_2.png
abc141_3.png
abc141_4.png
abc141_5.png

そのまま解いた。

abc141c.py
N,K,Q = map(int,input().split())

memo = {}
for i in range(N):
    memo[i] = 0

for i in range(Q):
    a = int(input())
    memo[a-1] += 1

#print(memo)
for i in memo.keys():
    if K-(Q-memo[i]) > 0:
        print("Yes")
    else:
        print("No")
#208ms

collections.counter を使うやり方も面白いが、
使い慣れていないとミスを誘発するかもしれません。
ただ、辞書と違い、counter の中にない値は
error を吐かず、0 を return する使用は便利だと
思いました。

少しずつ慣れていこうと思います。

abc141c.py
def solv():
    N,K,Q = map(int,input().split())
    A = list(int(input()) for _ in range(Q))
    from collections import Counter
    A = Counter(A)
    for i in range(1,N+1):
        if Q-A[i] >= K:
            print("No")
        else:
            print("Yes")
solv()#194ms
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?