DSA Penalty Shootout

[https://www.codechef.com/LRNDSA02/submit/PSHOT]

Can anyone tell me why Iam Getting WA

You posted an incorrect link.
Provide a link to your submission.

https://www.codechef.com/LRNDSA02/submit/PSHOT

Its an incorrect link. Go to “My Submissions” and then post the link to your submission.

https://www.codechef.com/LRNDSA02/status/PSHOT,mohsina123

According to your latest solution, this is the test case which it fails on:

Input

1
5
1010100101

Your Output

10

Correct Output

6

Explanation

The first character is 1, therefore team A scored
Score = 1(1) - 0(0)
The number in bracket shows the number of shots taken by the team

The second character is 0, therefore team B missed
Score = 1(1) - 0(1)

The third character is 1, therefore team A scored
Score = 2(2) - 0(1)

The fourth character is 0, therefore team B missed
Score = 2(2) - 0(2)

The fifth character is 1 therefore team A scored
Score = 3(3) - 0(2)

The sixth character is 0 therefore team B missed
Score = 3(3) - 0(3)

Now you see, Team A has taken an unassailable lead. Team B has only 2 shots left, but 3 goals to score, which is not possible. Hence the correct answer is 6.

1 Like

Can you explain briefly what was your though process/logic to solve the problem?

However, the problem is simple all you need to do is simulate a penalty-shootout taken in a football match.

It was that anyone team should loose atleast two shots and other score (n-1) shoots.

Can anyone please help me by telling what is wrong with this?
https://www.codechef.com/viewsolution/35920719