1140B.md (2139B)
1 Source: https://codeforces.com/problemset/problem/1140/B 2 3 B. Good String 4 5 time limit per test 6 7 1 second 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 You have a string $s$ of length $n$ consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character <, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens). 22 23 For example, if we choose character > in string > > < >, the string will become to > > >. And if we choose character < in string > <, the string will become to <. 24 25 The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings >, > > are good. 26 27 Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $n - 1$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $s$ so that it becomes good. 28 29 Input 30 31 The first line contains one integer $t$ ($1 \le t \le 100$) – the number of test cases. Each test case is represented by two lines. 32 33 The first line of $i$-th test case contains one integer $n$ ($1 \le n \le 100$) – the length of string $s$. 34 35 The second line of $i$-th test case contains string $s$, consisting of only characters > and <. 36 37 Output 38 39 For each test case print one line. 40 41 For $i$-th test case print the minimum number of characters to be deleted from string $s$ so that it becomes good. 42 43 Example 44 45 Input 46 47 ``` 48 3 49 2 50 <> 51 3 52 ><< 53 1 54 > 55 ``` 56 57 Output 58 59 ``` 60 1 61 0 62 0 63 ``` 64 65 Note 66 67 In the first test case we can delete any character in string <>. 68 69 In the second test case we don't need to delete any characters. The string > < < is good, because we can perform the following sequence of operations: > < < $\rightarrow$ < < $\rightarrow$ <.