Search of the Sum
Ограничения: время – 200ms/500ms, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод
Послать решение Blockly Посылки Темы Где Обсудить (0)
The sequence of `M` integers is given. Find here the longest continuous subsequence with the sum of terms equal to given `S`.
Input
The first line of the input file contains two integers `M` and `S`, separated by one space, where `M` is the quantity of numbers in the sequence (`2\ ≤\ M\ ≤\ 30000`) and `S` is the value for the sum of terms of a subsequence (`0\ ≤\ S\ ≤\ 1000`). The following `M` lines contain a single integer `n` in a line (`-10000\ ≤\ n\ ≤\ 10000`).
Output
On the first line of the output file write two integers `F` and `L`, separated by one space, where `F` is the index of the first term of the retrieved subsequence (indexing starts from 1), and `L` is the length of the retrieved subsequence. If there are some equally long subsequences, indicate the first of them in the source sequence. If a subsequence with the given sum of terms is missing, write two zeros, separated by one space.
Условие задачи на русском языке