본문 바로가기
알고리즘 & 자료구조/백준

백준 11047

by 신재권 2021. 11. 2.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main11047 {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken()); // 동전의 종류 N
		int K = Integer.parseInt(st.nextToken()); // 가치의 합 K 
		// 동전 개수의 최소값을 구함
		int coinType[] = new int[N];
		for(int i=0; i<N; i++){
			coinType[i] = Integer.parseInt(br.readLine());
		}
		
		int cnt = 0;
		for(int i=N-1; i>=0; i--){
			cnt += K / coinType[i];
			K %= coinType[i];
		}
		System.out.println(cnt);
		
	}

}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 2798  (0) 2021.11.05
백준 1931  (0) 2021.11.03
백준 5585  (0) 2021.11.01
백준 1107  (0) 2021.09.30
백준 1476  (0) 2021.09.25