CF725A.Jumping Ball
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are two types of bumpers. They are denoted by the characters '<' and '>'. When the ball hits the bumper at position i it goes one position to the right (to the position i + 1) if the type of this bumper is '>', or one position to the left (to i - 1) if the type of the bumper at position i is '<'. If there is no such position, in other words if i - 1 < 1 or i + 1 > n, the ball falls from the game field.
Depending on the ball's starting position, the ball may eventually fall from the game field or it may stay there forever. You are given a string representing the bumpers' types. Calculate the number of positions such that the ball will eventually fall from the game field if it starts at that position.
在著名弹珠游戏(Pinball)的一个新版本中,游戏场地最重要的部分之一是由 n 个挡板(bumper)组成的序列。这些挡板从左到右依次编号为 1 到 n。挡板有两种类型,分别用字符 < 和 > 表示。当小球击中位置 i 处的挡板时,若该挡板类型为 >,则小球向右移动一个位置(即到达位置 i+1);若该挡板类型为 <,则小球向左移动一个位置(即到达位置 i−1)。如果目标位置不存在——即若 i−1<1 或 i+1>n——则小球将从游戏场地掉落。
根据小球的起始位置不同,它最终可能从游戏场地掉落,也可能永远留在场地上(即陷入无限循环)。现给你一个表示各挡板类型的字符串,请计算有多少个起始位置,使得小球从该位置出发后最终会从游戏场地掉落。
输入格式
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the length of the sequence of bumpers. The second line contains the string, which consists of the characters '<' and '>'. The character at the i-th position of this string corresponds to the type of the i-th bumper.
输入的第一行包含一个整数 n(1 ≤ n ≤ 200000)——表示缓冲器序列的长度。
第二行包含一个字符串,该字符串仅由字符 < 和 > 组成。该字符串中第 i 个位置上的字符对应第 i 个缓冲器的类型。
输出格式
Print one integer — the number of positions in the sequence such that the ball will eventually fall from the game field if it starts at that position.
输出一个整数——表示序列中满足条件的位置个数:若小球从该位置开始运动,则最终会从游戏区域掉落。
输入输出样例
输入#1
4 <<><
输出#1
2
输入#2
5 >>>>>
输出#2
5
输入#3
4 >><<
输出#3
0
说明/提示
In the first sample, the ball will fall from the field if starts at position 1 or position 2.
In the second sample, any starting position will result in the ball falling from the field.
在第一个样例中,若小球从位置 1 或位置 2 开始运动,它将从场地上掉落。
在第二个样例中,任意起始位置都会导致小球从场地上掉落。
输入解题思路,AI测评打分。不知道怎么写?