Unable to submit CodeChef Hard Cash solution

Hello, this is my first time participating in CodeChef long challenge and I submitted the solution for the Hard Cash problem(my first submission). The solution seems working fine on VS Code but it is giving me an output of string of zeroes when I run on CodeChef. Am I missing something here?
I also included the code for the number of test cases. Should the output be given at the end for both the test cases or output after every test case finishes executing?

After each test case

Either - the Online Judge only cares about what output your program produces during its execution, not about at which point the output is produced. For non-interactive Problems, of course :slight_smile:

1 Like

check no of test cases loop.Make sure that you are reducing the variable for each testcase.
Hope this helps.

Yes I have done that. The output it is as required on VS Code. It just gives a sequence of 0s on CodeChef

So what might be the reason for different outputs on my laptop’s compiler and the online judge?

just before your functions type
using namespace std;
instead of
std::cin

I have written the namespace.

It wasn’t written in your 2 submissions.

Haven’t I written it in the 3rd line?

I can’t read your long challenge submissions.
These 2 submissions
https://www.codechef.com/viewsolution/25213046
https://www.codechef.com/viewsolution/25212957

I don’t think namespace is the issue here. I have written it in my challenge submission. And what do those sub tasks in the challenge signify?

Loads of possible reasons. Are you Running without providing Custom Input?

1 Like

Oh, thanks a lot! Even I was used to the Hackerrank system :stuck_out_tongue: Also, this subtask thing is confusing. Am I supposed to write different code for the 3 sub tasks?

1 Like

No :slight_smile: See e.g. here, and the other post linked from that post :slight_smile: