Logo
(追記) (追記ここまで)

13871번 - Farm robot 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB53338234572.785%

문제

To discourage birds such as crows and sparrows from feeding on his crops a farmer needed to put some scarecrows in his corn field. His nephew really likes robots, and suggested that he should use a robot scarecrow instead: “A single robot scarecrow can better protect the whole corn field and will last way more than ten traditional ones!”, he said.

Since the farmer thinks his nephew is a smart boy, he took his advice and bought a robot scarecrow. The robot moves along a pathway that surrounds the corn field. In the pathway there are N unmanned charging stations, numbered sequentially in clockwise order starting from 1. The figure below shows an example with eight charging stations.

The robot begins every day at station number 1, and is issued a sequence of commands that are to be performed in order during the day. These commands are generated based on advanced machine learning algorithms that work on data collected by sensors spread through the corn field, ensuring an optimal coverage of the crop. Each command results in the robot moving to another charging station next to the one it is currently at, either in clockwise or counter-clockwise direction.

Despite the promises of optimal coverage by the robot, at the end of a certain day the farmer found part of his crop devastated. To figure out what might have happened the farmer wants to know how many times the robot was at the charging station closest to the devastated area. Given the number of the station closest to the devastated area and the sequence of commands for a single day, can you help the farmer find this number?

입력

The first line contains three integers N, C and S representing respectively the number of posts (2 ≤ N ≤ 100), the number of commands (1 ≤ C ≤ 1000) and the charging station closest to the devastated area (1 ≤ S ≤ N). The second line contains C integers X1, X2, . . . , XC , representing the sequence of commands received by the robot scarecrow. For i = 1, 2, . . . , C, if Xi is 1 then the i-th command means “move to the next charging station in clockwise order”, whereas if Xi is −1 then the i-th command means “move to the next charging station in counter-clockwise order”. The robot always starts at station number 1.

출력

Output a line with an integer representing the number of times the robot was at station number S during the day.

제한

예제 입력 1

8 8 3
1 -1 1 1 1 -1 1 1

예제 출력 1

2

예제 입력 2

5 4 1
1 1 1 1

예제 출력 2

1

예제 입력 3

2 1 1
1

예제 출력 3

1

예제 입력 4

2 1 2
1

예제 출력 4

1

예제 입력 5

2 2 1
-1 1

예제 출력 5

2

예제 입력 6

2 2 1
-1 -1

예제 출력 6

2

힌트

출처

ICPC > Regionals > Latin America > Latin America Regional Contests > Latin America Regional Contests 2016 F번

  • 문제를 만든 사람: Ricardo Anido
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /