#647
Unrated
Target Practice
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie is a robovine, also known as a cowborg. She is on a number line trying to shoot a series of TT (1T105)(1 \leq T \leq 10^5) targets located at distinct positions. Bessie starts at position 00 and follows a string of CC (1C105)(1 \leq C \leq 10^5) 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 TT and CC.

The next line contains the locations of the TT targets, distinct integers in the range [C,C][-C,C].

The next line contains the command string of length CC, 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

예제 출력 1

3

예제 입력 2

1 5
0
FFFFF

예제 출력 2

1

예제 입력 3

5 6
1 2 3 4 5
FFRFRF

예제 출력 3

3

점수

Inputs 4-6: T,C1000T,C \le 1000Inputs 7-15: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.