-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGreedy-PP3.c
More file actions
40 lines (40 loc) · 730 Bytes
/
Greedy-PP3.c
File metadata and controls
40 lines (40 loc) · 730 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
38
39
40
#include<stdio.h>
int main()
{
int n,bill,five=0,ten=0,twenty=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&bill);
if(bill==5)
five++;
else if(bill==10)
{
if(five>0)
{
five--;
ten++;
}
else
{
printf("false");
return 0;
}
}
else
{
if(ten>0 && five>0)
{
five--;
ten--;
twenty++;
}
else
{
printf("false");
return 0;
}
}
}
printf("true");
}