- محدودیت زمان: ۱ ثانیه
- محدودیت حافظه: ۲۵۶ مگابایت
Mohsen and Mohammadreza are teammates. They are participating in Codeforces’es contest called Gym every week. Like always Mohammadreza was late, so Mohsen started calling him. Their cellphones are always in silent mode so they don’t understand if someone is calling them. Mohsen kept calling and finally gave up. They both always check their cellphones every 10 hours. When Mohammadreza checks his cellphone he sees lots of missed calls!!! so he starts calling back Mohsen. Mohsen misses them too, Then, Mohsen checks his cellphone and starts calling Mohammadreza and this continues for hours. They can’t reach each other and because of that they miss the contest. Mohsen got bored so he started to make a problem for Newbies Contest.
He wrote number of times they called each other on a paper. He wrote number of Mohsen’s miss calls as a positive number and number of Mohammadreza’s miss calls as a negative number. Mohsen was wondering what is the longest interval that multiply of numbers within it, is maximum among any other interval?
ورودی
First line of input contains an integer $T(T \le 100)$ indicating number of test cases. Each test case contains two lines. First line contains an integer $N(1 ≤ N ≤ 100)$ indicating number of times they called each other. Second line contains a list of non-zero integers $a_1 ,a_2 ,\dots,a_n (a_i ≤ 50)\space$ separated with spaces. It’s guaranteed there is at least one negative integer in every 10 consecutive integers. NOTE: It’s possible that only one of them calls other person.
خروجی
For each test case print a line containing two integers $L$ and $R$ separated with a single space, indicating the interval $[L, R]$, where answer of $a_L \times a_{L+1} \times\dots\times a_R \space$ is maximum. If there is more than one solution, print the one with smaller $L$ and then longer interval.
مثالها
ورودی نمونه ۱
3
5
1 2 3 -4 -5
5
10 21 -3 40 38
5
5 20 -3 5 20
خروجی نمونه ۱
1 5
4 5
1 2
ارسال پاسخ برای این سؤال