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

13085번 - Line Gimmick 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB99574457.143%

문제

You are in front of a linear gimmick of a game. It consists of N panels in a row, and each of them displays a right or a left arrow.

You can step in this gimmick from any panel. Once you get on a panel, you are forced to move following the direction of the arrow shown on the panel and the panel will be removed immediately. You keep moving in the same direction until you get on another panel, and if you reach a panel, you turn in (or keep) the direction of the arrow on the panel. The panels you passed are also removed. You repeat this procedure, and when there is no panel in your current direction, you get out of the gimmick.

For example, when the gimmick is the following image and you first get on the 2nd panel from the left, your moves are as follows.

  • Move right and remove the 2nd panel.
  • Move left and remove the 3rd panel.
  • Move right and remove the 1st panel.
  • Move right and remove the 4th panel.
  • Move left and remove the 5th panel.
  • Get out of the gimmick.

You are given a gimmick with N panels. Compute the maximum number of removed panels after you get out of the gimmick.

입력

The input consists of two lines. The first line contains an integer N (1 ≤ N ≤ 100,000) which represents the number of the panels in the gimmick. The second line contains a character string S of length N, which consists of '>' or '<'. The i-th character of S corresponds to the direction of the arrow on the i-th panel from the left. '<' and '>' denote left and right directions respectively.

출력

Output the maximum number of removed panels after you get out of the gimmick.

제한

예제 입력 1

7
>><><<<

예제 출력 1

7

예제 입력 2

5
>><<<

예제 출력 2

5

예제 입력 3

6
><<><<

예제 출력 3

6

예제 입력 4

7
<<><<>>

예제 출력 4

5

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Practice Contest for ICPC Asia Regional > JAG Practice Contest for ACM-ICPC Asia Regional 2015 D번

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

출처

대학교 대회

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

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