백준 11047

김경욱·2025년 8월 24일

백준

목록 보기
55/121

import java.util.;
import java.io.
;

// 1 10 13 16
public class Main {
public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    StringTokenizer st = new StringTokenizer(br.readLine());
    int count = 0;
    int N = Integer.parseInt(st.nextToken());
    int M = Integer.parseInt(st.nextToken());

int[] coins = new int[N];

    for (int i = 0; i < N; i++) {
        coins[i] = Integer.parseInt(br.readLine());
    }

    for (int i = N-1; i >= 0; i--)
    {
        if (M / coins[i] >= 1)
        {
            count = count + (M / coins[i]);
            M = M % coins[i];


        }


    }
    System.out.println(count);
















}

}

이게 이렇게 풀리구나...

0개의 댓글