# Why is this getting WA? (CHEFAPAR)

Here is my code: https://www.codechef.com/viewsolution/15902557
I can’t understand, where am I wrong in my approach?

Thanks a lot!

Consider this case-

1 1 0

The answer is 1100, but your code will print 1300 if I am not wrong.

1 Like

A little bit. Drop me a mail where you need help, or refer here - http://www.geeksforgeeks.org/operator-overloading-c/

I sent you an email discussing about my problem please look at it thank you

Because there isn’t any other question and editorial page about CHEFAPAR problem, i ask my question in here. According to below test cases my code is working correct. Which scenario/case am i miss? I also get WA.

https://www.codechef.com/viewsolution/16626910

According to below test cases it should be fine.

``````@Test
public void testInitialCases() {
assertEquals(0, CHEFAPAR.calculateDues("1 1"));
assertEquals(2200, CHEFAPAR.calculateDues("0 0"));
assertEquals(2300, CHEFAPAR.calculateDues("0 1 0"));
assertEquals(1200, CHEFAPAR.calculateDues("0 1"));
assertEquals(1100, CHEFAPAR.calculateDues("1 1 0"));
assertEquals(2300, CHEFAPAR.calculateDues("1 0 0 1"));
}
``````

Please check comments below, thanks to @kunnu120’s comment, i understand failed cases and my answer is accepted.

https://www.codechef.com/viewsolution/16630746

https://www.codechef.com/viewsolution/16628058 Look at my approach if it helps!!

In this problem, you just need to find the first occurrence of ‘0’ because if you’re late for one month then there is no way you can pay the maintenance fees on time. so first just run a simple for loop to see where you didn’t pay the fees and keep adding the fees which is 1000. and then at the end add ((N-first occurrence of 0)*100) to your fees. Hope it helps!!