Playing with cards(In stack)

It’s shwoing run error …

@Vivek-Pandey-2129725577345937
Hello vivek ,
you are not taking input correctly,
please check input format.
also
a)whenever u are referrring s.top() make sure s is not empty.

b) in line no 8 . when i=0 n%0 will give error

can you tell me about the input format how my input is wrong
here is my modified code …
output is coming same as input in this one.


@aman212yadav

@Vivek-Pandey-2129725577345937
image

as mentioned in input format you will be given only A0 but u are taking input for each iteration (which is wrong)

so then i will store it in array and store the first element of array in my stack
and then evaluate to all the condition. Right ?

@Vivek-Pandey-2129725577345937
yeah right.
when u are at ith iteration then use Ai-1 stack to find Ai and Bi.
in case i=1 then A0 stack is given to u.