Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help me with pythonBessie is a robovine, also known as a cowborg. She is on a number line trying to shoot a series of )
Help me with pythonBessie is a robovine, also known as a cowborg. She is on a number line trying to shoot a series of targets located at distinct positions. Bessie starts at position and follows a string of commands, each one of or :
L: Bessie moves one unit to the left.
R: Bessie moves one unit to the right
F: Bessie fires. If there is a target at Bessie's current position, it is hit and destroyed, and cannot be hit again.
If you are allowed to change up to one command in the string to a different command before Bessie starts following it what is the maximum number of targets that Bessie can hit?
INPUT FORMAT pipe stdin:
The first line contains and
The next line contains the locations of the targets, distinct integers in the range
The next line contains the command string of length containing only the characters and
OUTPUT FORMAT pipe stdout:
Print the maximum number of targets that Bessie can hit after changing up to one command in the string.
SAMPLE INPUT:
LFFRFRR
SAMPLE OUTPUT:
If you make no changes to the string, Bessie will hit two targets:
tableCommandPosition,Total Targets HitStartLFFRFRR
If you change the last command from R to F Bessie will hit all three targets:
tableCommandPosition,Total Targets HitStartLFFRF
R
F
SAMPLE INPUT:
FFFFF
SAMPLE OUTPUT:
If the commands are left unchanged, the only target at will be destroyed. Since a target cannot be destroyed multiple times, the answer is
SAMPLE INPUT:
FFRFRF
SAMPLE OUTPUT:
SCORING:
Inputs :
Inputs : No additional constraints.
Problem credits: Suhas Nagar
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started