Codeforces

Nezzar and Colorful Balls

john.k 2021. 1. 31. 22:52
반응형

Codeforces Round #698 (Div. 2)

A. Nezzar and Colorful Balls

https://codeforces.com/contest/1478/problem/A

 

Problem - A - Codeforces

 

codeforces.com

문제 전문은 위 링크에서 확인하실 수 있습니다.

# https://codeforces.com/contest/1478/problem/A

ans = []
n = int(input())
for _ in range(n):
    length = int(input())
    arr = [int(i) for i in input().split()]
    maxv = 0
    for i in range(1,length+1):
        if maxv <= arr.count(i):
            maxv = arr.count(i)
    ans.append(maxv)
for i in ans:
    print(i)

 

가장 많이 중복되는 수의 개수만큼 색이 필요합니다.

1부터 n까지 돌면서 가장 많이 중복된 수를 찾아서 배열에 담은 후 한번에 출력하였습니다.

반응형