Please help me in WDTBAM

,

https://www.codechef.com/viewsolution/15134038 My submission for “Who dares to be a millionaire”.I’m getting an AC in Subtask #2 but not in #1? Can someone please explain why this is happening? Sorry for annoying by asking questions everyday.I’m a newbie at programming.

It is a simple question. What is your Pov? I might help you simplify/refine your approach.

What the Q actually states is, that you know by 2 strings that how many Q the candidate will correctly answer . You also know the prize if he answers 0 Q correctly, 1 Q correctly, 2 Q correctly…and so on.

If he answered K Q correctly, he can get any value in between {{W_0},{W_1},....{W_k}} . (Because, the sequence of answering Q is NOT as given in string. The Q can be asked in any sequence, and we are given that for this Q the answer is corresponding char in other string. It is possible that all K Q (for which he knows answer) get asked consecutively.

Now we simply have to choose the maximum among them. Eg, if {W_3}>{W_4} , he can get {W_3} money if he answers fourth Q incorrectly (The order of Q can be anything!! Consider the order in which you get maximum winning).

PS: Take care when he answers all Q correctly. In this case he has no choice but take {W_n}

I understood the question correctly.I even added exception cases of ALL RIGHT ANSWERS and NO RIGHT ANSWERS.Im even getting an AC in Task#2 of Subtask 2.What i want to know is where im going wrong for Subtask 1 and Task#1 of Subtask 2.The outputs also seem 100% correct to me.

The way i approached this question is:Count the number of right answers he gave.Then find out the maximum winning in the array.If the no. of right answers >= The index of the max winning,Print that value and repeat.If right answers is less,Find out the 2nd largest winning,check if right >= index and so on.Also the exception cases have been added in If and Else cases

Your code gets runtime error here-

1
5
ABCDE
ABCED
10 200 10 10 10 20

Check it on codechef compiler. The runtime error is due to unintialized variables (count variable)

The codechef IDE is messed up.I initialized both count and track to 0.Still getting a wrong answer in codechef.My IDE is giving me 200.Im confused.

Really? I just initialized count to 0 and got 200. Let me have a look. PS: Judge executes program just like codechef IDE :stuck_out_tongue:

EDIT: Its giving me 200 output in codechef IDE :confused:


Here is my proof.By the way,is my approach to this question correct?

Sorry, typo, its giving me 200. Basically, are you getting correct output on codechef ide and wa on submit OR are you getting messed up output at ide? (Confused cause u said ide is broken)

Just WA on submission.Worst part is I dont know where i’m making the mistake.

Your code doesnt print anything for this case-

1
2
ZC
AC
10 43 500

Check your variable “track”


I fixed it.Still getting WA.Please help me get AC

Heres the next test case-

Input
1
3
ZDB
ACB
100 4 500 600
Your Output
4
Expected Output
100 (if he gets first Q wrong)

HAHA.HERE IS MY MISTAKE.YOU ARE THE BOSS.Thank you so much.

And @kriskhundu got a double kill, 2 sub-tasks at once XD :smiley: . Glad you got AC :slight_smile:

PS: please dont use award point feature!! It reduces your karma!! For accepting answers, click on the tick below downvote sign. :slight_smile: