728x90
반응형
# 볼링공 고르기
n, m = map(int,input().split())
data = list(map(int, input().split()))
# n은 공의 수, m 은 최대 무게
# 서로 다른 무게를 골라야함..
cnt = 0
next = 0
for index in range(n):
next = index +1
while next < n :
if data[index] != data[next]:
cnt += 1
next += 1
print (cnt)
# 볼링공의 최대 무게를 활용해 보자
n, m = map(int,input().split())
data = list(map(int, input().split()))
array = [ 0 ] * 11
for x in data:
array[x] += 1
cnt = 0
for i in range(1, m+1 ):
n -= array[i]
cnt += array[i] * n
print (cnt)
728x90
반응형
'알고리즘 > 이것이 취업을 위한 코딩테스트다' 카테고리의 다른 글
06-3. 성적이 낮은 순서로 학생 출력하기 (0) | 2020.09.09 |
---|---|
11-06. 무지의 먹방 라이브 (0) | 2020.09.03 |
04-2. 시각 (0) | 2020.09.03 |
04-1. 상하좌우 (0) | 2020.09.03 |
11-02. 곱하기 또는 더하기 (0) | 2020.09.02 |