WDTBAM - Editorial

I am a bit new here and a little help would be greatly appreciated. I tried the below code on Turbo C++, and it worked but here it says wrong answer. Any ideas why that may be?

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

like everyone else: I can’t get this to work on the submission. It works on the sample data and I’ve compared to some of the completed solutions and it looks equivalent to me but I still get a WA.

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

T=int(input())
for t in range(0,T):
N=int(input())
ca=input()
ga=input()
count=0
winnings=[]
win=list(map(int,input().split()))
for i in range(0,len(ca)):
if ca[i]==ga[i]:
count=count+1
if count==0:
print(win[0])
else:
for i in range(1,count+1):
winnings.append(win[i])
print(max(winnings))

Whats the problem in this code? I cant find it :frowning:

Whats the problem in this code? I cant find it :frowning:

can any tell whats wrong withthis code
am getting correct answer in PC i gave the sample inputs getting same sample output but complilng in CodeChef showing wrong sir.please help me

Why goes it give a WA? I’m sure my solution is similar to what the editorial says.
https://www.codechef.com/viewsolution/12383128

Whats wrong with my code 0Jp7oi - Online C++0x Compiler & Debugging Tool - Ideone.com

“If K = N, there is no other option than Chef answers all the questions correctly and gets WN dollars of profit.”

for (j=0; j<1001; j++)
W[i]=0;

The above line is wrong. make it,

for (j=0; j<1001; j++)
W[j]=0;

This gives 100pts

You are not considering the case where all the answers are correct.

Your modified code :
https://www.codechef.com/viewsolution/8530809

This gives AC

Thanks for pointing it out. Really feeling bad that I missed 80 points due to that! :frowning:

@prasadram126 Please change long int to long long int and then try again. The constraints of the problem are such that they need a datatype as large as long long int.
This is the link to your updated solution.
https://www.codechef.com/viewsolution/8535868

@anuragkumar33 I think you need to make arrays A and B a little bit bigger (say, 1010), because string of length N needs N + 1 byte of memory (string itself plus ‘\0’).

If cnt = n, Chef answers all questions correctly and there is no other option than Chef gets W_n dollars of profit, because he can’t leave the game when he wants. For example, for test

3

ABC

ABC

10 100 20 30

answer is 30, not 100.

2 Likes

And again, for test

3

ABC

ABC

10 100 20 30

answer is 30, not 100.

1 Like

@raunak_parijat thanks for you help , i have one question, in the problem page value of wi at max 10^9 i have tested my code with 10^9 it’s working fine .So can you please give me any test case where it’s giving WA?

@eartemov thanks a lot for the help

Can anyone point out my mistake in my submission?
https://www.codechef.com/viewsolution/25936370

can anyone help me . my solution is not working ???
https://www.codechef.com/viewsolution/32110633

it will be a great help.