지폐, 동전 구분 #알고리즘 과제

이동호·2022년 10월 21일
0
import sys

input = sys.stdin.readline

n=int(input())
m=int(input())
bucket=[0] * 7

value=[0, 100, 500, 1000, 5000, 10000, 50000]

cur=list(map(int,input().split()))
# 지폐는 3부터 시작 3:1,000, ~ 6:50,000
for i in range(n):
  cur[i] += 2
  
# 코인은 1부터 2까지  
cur.extend(list(map(int,input().split())))

def counting_sort(cur, bucket):
  tot=0
  for ele in cur:
    bucket[ele] += 1
    tot += value[ele]
  for i in range(len(bucket)-1, 0, -1):
    if i != 1:
      print(f"(₩{value[i]}, {bucket[i]}),", end=' ')
    else:
      print(f"(₩{value[i]}, {bucket[i]})")
  print(f"(Sum, {tot})", end='')  

counting_sort(cur, bucket)
profile
안녕

0개의 댓글