-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM_Machine.java
More file actions
31 lines (29 loc) · 965 Bytes
/
ATM_Machine.java
File metadata and controls
31 lines (29 loc) · 965 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
27
28
29
30
31
import java.util.Scanner;
public class ATM_Machine {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
for(int i = 0; i < t ; i++){
String str = sc.nextLine();
// sc.nextLine();
String amt = sc.nextLine();
String[] strNK = str.split(" ");
int N = Integer.parseInt(strNK[0]);
String[] N_amt = amt.split(" ");
int K = Integer.parseInt(strNK[1]);
int[] amount = new int[N];
for(int j = 0; j < N; j ++){
amount[j] = Integer.parseInt(N_amt[j]);
}
for(int k = 0 ; k< N; k++){
if(amount[k]<= K){
K = K - amount[k];
System.out.print("1");
}
else System.out.print("0");
}
System.out.println();
}
}
}