RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0584

Target Practice

Silver II 실버 II
난이도
2s
시간 제한
256MB
메모리 제한
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 \(T\) \((1 \leq T \leq 10^5)\) targets located at distinct
positions. Bessie starts at position \(0\) and follows a string of \(C\)
\((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?

Problem credits: Suhas Nagar

제약

SCORING

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

Problem credits: Suhas Nagar

입력 형식

The first line contains \(T\) and \(C\).

The next line contains the locations of the \(T\) targets, distinct integers in the range
\([-C,C]\).

The next line contains the command string of length \(C\), 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
설명

If you make no changes to the string, Bessie will hit two targets:

Command | Position | Total Targets Hit
--------+----------+-------------------
Start   |  0       | 0
L       | -1       | 0
F       | -1       | 1
F       | -1       | 1 (can't destroy target more than once)
R       |  0       | 1
F       |  0       | 2
R       |  1       | 2
R       |  2       | 2

If you change the last command from R to F, Bessie will hit all three targets:

Command | Position | Total Targets Hit
--------+----------+-------------------
Start   |  0       | 0
L       | -1       | 0
F       | -1       | 1
F       | -1       | 1 (can't destroy target more than once)
R       |  0       | 1
F       |  0       | 2
R       |  1       | 2
F       |  1       | 3
예제 2
입력
1 5
0
FFFFF
출력
1
설명

If the commands are left unchanged, the only target at 0 will be destroyed.
Since a target cannot be destroyed multiple times, the answer is 1.

예제 3
입력
5 6
1 2 3 4 5
FFRFRF
출력
3
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2023-2024 > December > Silver

태그

평가 및 의견

Target Practice

개요
출제자 난이도 Silver II 실버 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Target Practice

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8