codeforces-scrape

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

641A.md (1595B)


      1 Source: https://codeforces.com/problemset/problem/641/A
      2 
      3 A. Little Artem and Grasshopper
      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 Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.
     22 
     23 The area looks like a strip of cells 1 × *n*. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first cell and follows the instructions written on the cells. Grasshopper stops immediately if it jumps out of the strip. Now Artem wants to find out if this will ever happen.
     24 
     25 Input
     26 
     27 The first line of the input contains a single integer *n* (1 ≤ *n* ≤ 100 000) — length of the strip.
     28 
     29 Next line contains a string of length *n* which consists of characters "<" and ">" only, that provide the direction of the jump from the corresponding cell. Next line contains *n* integers *d**i* (1 ≤ *d**i* ≤ 109) — the length of the jump from the *i*-th cell.
     30 
     31 Output
     32 
     33 Print "INFINITE" (without quotes) if grasshopper will continue his jumps forever. Otherwise print "FINITE" (without quotes).
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 2  
     41 ><  
     42 1 2
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 FINITE
     49 ```
     50 
     51 Input
     52 
     53 ```
     54 3  
     55 >><  
     56 2 1 1
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 INFINITE
     63 ```
     64 
     65 Note
     66 
     67 In the first sample grasshopper starts from the first cell and jumps to the right on the next cell. When he is in the second cell he needs to jump two cells left so he will jump out of the strip.
     68 
     69 Second sample grasshopper path is 1 - 3 - 2 - 3 - 2 - 3 and so on. The path is infinite.