-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ11047.java
More file actions
26 lines (22 loc) · 734 Bytes
/
Copy pathJ11047.java
File metadata and controls
26 lines (22 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package TIL;
import java.io.*;
public class J11047 {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String[] input = bufferedReader.readLine().split(" ");
int n = Integer.parseInt(input[0]);
int value = Integer.parseInt(input[1]);
int[] coin = new int[n];
for(int i = 0; i <n; i++){
coin[i] = Integer.parseInt(bufferedReader.readLine());
}
int cnt = 0;
while(value!=0){
if(coin[--n] <= value){
cnt += value/coin[n];
value %= coin[n];
}
}
System.out.println(cnt);
}
}