Pro.ID22173 TitleRebuild The Great Wall Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22173 AC0 Submit0 Ratio- 时间&空间限制描述In 1368 A.D., in China, the king Yuanzhang Zhu won the war and build up the Ming dynasty, we've talked about that before. To resist Mongolian army, the King decided to rebuild the Great Wall. However, the Kingdom spent quite a lot of money on the project before (If you are confuse, please check out the former problem! ^_^), they can only rebuild part of the Great Wall. There're many segments of Great Wall from west to east. For every segment, there's an integer number as resistant value. Now, the kingdom wants to continuously rebuild minimum segments that the sum of resistant value is greater than T. 输入There're several groups of data. For each group, the first line of Input contains two integer N ( N ≤ 100000 ) and T ( T ≤ 2*109 ). N means the number of segments of Great Wall, T was defined in background. And then N integers in one line present the resistant value of every segment from west to east. 输出Description In 1368 A.D., in China, the king Yuanzhang Zhu won the war and build up the Ming dynasty, we've talked about that before. To resist Mongolian army, the King decided to rebuild the Great Wall. However, the Kingdom spent quite a lot of money on the project before (If you are confuse, please check out the former problem! ^_^), they can only rebuild part of the Great Wall. There're many segments of Great Wall from west to east. For every segment, there's an integer number as resistant value. Now, the kingdom wants to continuously rebuild minimum segments that the sum of resistant value is greater than T. Input There're several groups of data. For each group, the first line of Input contains two integer N ( N ≤ 100000 ) and T ( T ≤ 2*109 ). N means the number of segments of Great Wall, T was defined in background. And then N integers in one line present the resistant value of every segment from west to east. Output Output one integer as the minimum number of continuously segments in one line. If there's no solution, print out -1 in one line. Sample Input 7 18 Sample Output 2 Source 样例输入7 18 样例输出2 作者 |