codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

725A.md (1969B)


      1 Source: https://codeforces.com/problemset/problem/725/A
      2 
      3 A. Jumping Ball
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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.
     24 
     25 Input
     26 
     27 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.
     28 
     29 Output
     30 
     31 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.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 4  
     39 <<><
     40 ```
     41 
     42 Output
     43 
     44 ```
     45 2
     46 ```
     47 
     48 Input
     49 
     50 ```
     51 5  
     52 >>>>>
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 5
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 4  
     65 >><<
     66 ```
     67 
     68 Output
     69 
     70 ```
     71 0
     72 ```
     73 
     74 Note
     75 
     76 In the first sample, the ball will fall from the field if starts at position 1 or position 2.
     77 
     78 In the second sample, any starting position will result in the ball falling from the field.