-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathATM2.c
More file actions
37 lines (31 loc) · 667 Bytes
/
ATM2.c
File metadata and controls
37 lines (31 loc) · 667 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
33
34
35
36
37
//https://www.codechef.com/problems/ATM2
#include <stdio.h>
#include <string.h>
int main()
{
int t;
scanf("%d", &t);
for (int j = 0; j < t; j++)
{
int total, n, withdraw;
scanf(" %d", &n);
char output[n];
scanf(" %d", &total);
for (int i = 0; i < n; i++)
{
scanf(" %d", &withdraw);
if (withdraw <= total)
{
output[i] = '1';
total = total - withdraw;
}
else
{
output[i] = '0';
}
}
output[n]='\0';
printf("%s\n", output);
}
return 0;
}