how to solve this easy problem?

alt text

PS-Contest is over now

You can go through each row and count number of P and T

Let’s just intialize the result = 0;

Let’s say we have input:

P T P P P T (1st row)

T T T P P T (2nd row)

T P T P T P (3rd row)

add we can have two if statements to determine the result



else if(T>=P)

result+= P;

so in the first row we have P = 4 and T = 2

So it will go through the if statement now result = 2

Now second row P = 2 and T = 4

so now result will become 4

third row P = 3 and T = 3

result become 7

Correct me if I’m wrong

Hope this helps!!

what about value of k?