Hello, so I’m new here and I’m also new in programming. I tried to solve the RECNDNOS practice problem, but I kept getting the run-time error when submitting it. While the code passed the supplied test cases quite nicely. So eventually I’ve figured out that I should pass 1001 instead of N+1 in the dish_types array declaration. And it’s also known that 1<= N <= 1000, so I understand from where the number 1001 comes from. The question is why N+1 gives me the run-time error on the submission test cases???!
dish type can be up to 1000 irrespective of n.
How could you have more dish types than dishes? In the description of the input it says that “The second line contains N integers A1,A2,…,AN”. Doesn’t it mean that each set of N dishes can have no more than N dish types in it?
@sadf_13 You are confusing between the type of dish and count of dish of that type. In the output, you have to print an integer with the smallest type of dish.
Well obviously I don’t have all the code posted here, because I can’t see how the end of it relates to my problem. But I print the right thing to the output. Again, my code with N+1 as length of the dish_types array works perfectly fine for simple test cases they put as an example, as well as for several my own. It wasn’t working only when I tried to submit it.
Here is a test case for which it is going to fail.
500 250 500
Oh thanks a lot I got it now!