다른 풀이n, m = map(int, input().split())arr = []for _ in range(n): arr.append(int(input()))arr.sort(reverse=True)count = 0for i in arr: if m % i == 0: count += m // i m -= i * (m // i)if m == 0: print(count)else: print(-1)
분류 전체보기
다른풀이n = int(input())arr = []for _ in range(n): arr.append(input().rstrip())arr = sorted(arr, reverse=True)print(" ".join(arr))
다른 풀이 1n = int(input())a = list(input().split())posX, posY = 1, 1move = ['L', 'R', 'U', 'D']dx = [-1, 1, 0, 0]dy = [0, 0, -1, 1]for i in a: k = move.index(i) if posX + dx[k] 다른 풀이 2n = int(input())way = list(input().split())move = [[0, -1], [0, 1], [1, 0], [-1, 0]]direction = ['L', 'R', 'D', 'U']start = [1, 1]for i in way: for k in range(len(direction)): if direction[k] == i: ..