-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathATM_Machine.cpp
More file actions
32 lines (30 loc) · 798 Bytes
/
Copy pathATM_Machine.cpp
File metadata and controls
32 lines (30 loc) · 798 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
32
#define ll long long
#define f(end) for(int i=0;i<end;i++)
#define e '\n'
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t,n,k;
cin>>t;
while(t--)
{
int temp;
string ans="";
cin>>n>>k;
f(n){
cin>>temp;
if(temp<=k){
ans+='1';
k-=temp;
}
else ans+='0';
}
cout<<ans<<e;
}
return 0;
}
// we took an empty string and for each input for the amount that specific person need, if it was less than the amount in the
// ATM i appended '1' to the answer string and decremented it from total amount denoting that the person has withdrawled the
// amount else if person is not able to withdraw money then we simple append 0 to answer string