Skip to content

Commit 3742758

Browse files
Add files via upload
1 parent 186dc3a commit 3742758

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <stdio.h>
2+
3+
void solve()
4+
{
5+
const int fine = 100, maintenance = 1000;
6+
int number_of_months, i, number_of_unpaid_months = 0, due, paid, number_of_late_months = 0;
7+
scanf("%d", &number_of_months);
8+
9+
for(i = 1; i <= number_of_months; i++)
10+
{
11+
scanf("%d", &paid);
12+
13+
if(paid == 0)
14+
{
15+
number_of_unpaid_months++;
16+
if(number_of_late_months == 0)
17+
{
18+
number_of_late_months = (number_of_months - i + 1);//After the first month that is missed, every month is late
19+
}
20+
}
21+
}
22+
23+
due = number_of_unpaid_months*maintenance + number_of_late_months*fine;
24+
printf("%d\n",due);
25+
}
26+
27+
int main()
28+
{
29+
int no_of_queries;
30+
scanf("%d", &no_of_queries);
31+
while(no_of_queries-- != 0)
32+
solve();
33+
34+
return 0;
35+
}

0 commit comments

Comments
 (0)