Target Practice
시간 제한: 2000ms메모리 제한: 1024MB출처: USACO 2023 December SilverBOJ 31062
문제
Bessie 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 L, F, or R:
- 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?
입력
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 F, L, and R.
출력
Print the maximum number of targets that Bessie can hit after changing up to one command in the string.
예제
예제 1
입력
3 7 0 -1 1 LFFRFRR
출력
3
예제 2
입력
1 5 0 FFFFF
출력
1
예제 3
입력
5 6 1 2 3 4 5 FFRFRF
출력
3
코드를 제출하려면 로그인하세요.