24 hour archive: Problem
2534 - Arrow Flips 2534 - Arrow Flips 2534 - Arrow Flips
Statistics | Sub: 854 | AC: 213 | AC%: 24,94 | Score: 0,98 |
Created by | Carlos Joa Fong |
Added by | ymondelo20 (2013-09-28) |
Limits |
Total Time: 30000 MS
|
Test Time:
4000 MS
|Memory: 62 MB | Output: 64 MB | Size:
14 KB
|
Enabled languages | |
Available in |
![]() |
Description
Let S be a string consisting of left arrow characters “<” and right arrow characters “>”. You are allowed to change at most K of these characters to their corresponding opposite arrow characters. That is, if a character is “>”, you may change it to “<” and vice versa. Once a character is changed, you may not change it again.
What is the length of the longest run of consecutive arrows pointing in the same direction after making these changes? A run of consecutive arrows is a substring of the modified string S that consists of the same arrow character. The longest such run is the one with maximum length.
What is the length of the longest run of consecutive arrows pointing in the same direction after making these changes? A run of consecutive arrows is a substring of the modified string S that consists of the same arrow character. The longest such run is the one with maximum length.
Let S be a string consisting of left arrow characters “<” and right arrow characters “>”. You are allowed to change at most K of these characters to their corresponding opposite arrow characters. That is, if a character is “>”, you may change it to “<” and vice versa. Once a character is changed, you may not change it again.
What is the length of the longest run of consecutive arrows pointing in the same direction after making these changes? A run of consecutive arrows is a substring of the modified string S that consists of the same arrow character. The longest such run is the one with maximum length.
What is the length of the longest run of consecutive arrows pointing in the same direction after making these changes? A run of consecutive arrows is a substring of the modified string S that consists of the same arrow character. The longest such run is the one with maximum length.
Let S be a string consisting of left arrow characters “<” and right arrow characters “>”. You are allowed to change at most K of these characters to their corresponding opposite arrow characters. That is, if a character is “>”, you may change it to “<” and vice versa. Once a character is changed, you may not change it again.
What is the length of the longest run of consecutive arrows pointing in the same direction after making these changes? A run of consecutive arrows is a substring of the modified string S that consists of the same arrow character. The longest such run is the one with maximum length.
What is the length of the longest run of consecutive arrows pointing in the same direction after making these changes? A run of consecutive arrows is a substring of the modified string S that consists of the same arrow character. The longest such run is the one with maximum length.
Input specification
First line of input contains the number of test cases T (T <= 20) to follow.
Each test case consists of integer K and string S separated by a single space on a single line. S consists of “<” and “>” characters. Constraints: 1 <= |S| <= 100000, 0 <= K <= |S|.
Each test case consists of integer K and string S separated by a single space on a single line. S consists of “<” and “>” characters. Constraints: 1 <= |S| <= 100000, 0 <= K <= |S|.
First line of input contains the number of test cases T (T <= 20) to follow.
Each test case consists of integer K and string S separated by a single space on a single line. S consists of “<” and “>” characters. Constraints: 1 <= |S| <= 100000, 0 <= K <= |S|.
Each test case consists of integer K and string S separated by a single space on a single line. S consists of “<” and “>” characters. Constraints: 1 <= |S| <= 100000, 0 <= K <= |S|.
First line of input contains the number of test cases T (T <= 20) to follow.
Each test case consists of integer K and string S separated by a single space on a single line. S consists of “<” and “>” characters. Constraints: 1 <= |S| <= 100000, 0 <= K <= |S|.
Each test case consists of integer K and string S separated by a single space on a single line. S consists of “<” and “>” characters. Constraints: 1 <= |S| <= 100000, 0 <= K <= |S|.
Output specification
For each test case, output the length of the longest run of arrow characters on a single line.
For each test case, output the length of the longest run of arrow characters on a single line.
First line of input contains the number of test cases T (T <= 20) to follow.
Each test case consists of integer K and string S separated by a single space on a single line. S consists of “<” and “>” characters. Constraints: 1 <= |S| <= 100000, 0 <= K <= |S|.
Each test case consists of integer K and string S separated by a single space on a single line. S consists of “<” and “>” characters. Constraints: 1 <= |S| <= 100000, 0 <= K <= |S|.
Sample input
3
2 <<>>
4 <><><><><
3 <>>>>><
Sample output
4
9
7
Hint(s)
http://coj.uci.cu/24h/
http://coj.uci.cu/24h/
http://coj.uci.cu/24h/