Kirinriki

TimeLimit:2000MS  MemoryLimit:65536KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
We define the distance of two strings A and B with same length n is
$dis_{A,B} = \sum\limits_{i=0}^{n-1}|A_{i}-B_{n-1-i}|$
The difference between the two characters is defined as the difference in ASCII.
You should find the maximum length of two non-overlapping substrings in given string S, and the distance between them are less then or equal to m.
Input
The first line of the input gives the number of test cases T; T test cases follow.
Each case begins with one line with one integers m : the limit distance of substring.
Then a string S follow.

Limits
$T \leq 100$
$0 \leq m \leq 5000$
Each character in the string is lowercase letter, $2 \leq |S| \leq 5000$
$\sum |S| \leq 20000$
Output
For each test case output one interge denotes the answer : the maximum length of the substring.
SampleInput
1
5
abcdefedcb
SampleOutput
5

 Hint[0, 4] abcde [5, 9] fedcb The distance between them is abs('a' - 'b') + abs('b' - 'c') + abs('c' - 'd') + abs('d' - 'e') + abs('e' - 'f') = 5
Submit
题目统计信息详细
总AC数3
通过人数3
尝试人数3
总提交量4
AC率75.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签
出处

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: