ALIEN - Aliens at the train


The aliens have arrived to Earth and everything is in harmony, the two races can live together. However, one specific Female Alien does not want to see humans on her way to the university, the alien must use the train as every human does. But she can choose any train station such she doesn’t see more than B humans, however, the Alien wants to go as far as possible with the train. Please, help her in this task.

Input

You will receive one integer T denoting the number of test cases, then, the next line will contain two integers At Bt where At and Bt is the number of stations in the train (1 <= At <= 100,000) and the number of people that the alien wants to see as maximum (1 <= Bt <= 10,000,000), after that, one line containing At integers separated by a single space will denote the number of people the Alien can find in the At-i-th station. (For each station there will be as much 100 people)

Output

Your output should consist on T pair of numbers denoting the number of people the alien will see and the number of stations she will pass respectively.

Example

INPUT:
1
5 100
20 15 30 80 100

OUTPUT
65 3

Output note:
The alien takes the train at station 1 (with 20 people) and goes to station 2, then the 3rd station, at this point, she have seen 65 people, if she decides to go to station 4 she will see 145 people… Then she exits the station.

The alien, however, can start at station 2 with 15 people, then continue up to the 4th station, then, she would have seen 125 people, but, as she wants to see the minimum people possible and this number of people exceeds what she wants to see, she decides to choose the way from the 1st to the 3rd station.

Clarification: The alien will be moving always forward (remember, she can choose any station as a start), NEVER backwards, and you should choose the best path that satisfies the output specification.


hide comments
prabodh prakash: 2017-05-14 15:19:50

Good question - a little deviation from standard sliding window code.

babu_nitdgp: 2017-03-22 12:33:11

Try these. Also care about the corner cases. :)
6 5
5 4 3 2 1 2
5 3
1 0
0
0 1
3 5
3 2 1
3 2
3 6
3 2 1
6 3
3 0
0 0 0
0 3
3 0
0 1 0
0 1
3 1
2 2 2
0 0
3 1
1 2 3
1 1

Last edit: 2017-03-22 12:33:52
vunnamtej: 2017-03-19 17:37:31

my 125th

vishalsingh: 2017-03-01 17:00:52

Very Easy
Can Boost your confidence... :)

cake_is_a_lie: 2017-02-22 23:14:13

#define endl '\n'
ios_base::sync_with_stdio(false);
cin.tie(NULL);

Use cin/cout; it's faster than scanf/printf.

Mayank Agarwal: 2017-01-16 11:05:06

use scanf/printf to prevent TLE

devbishnoi: 2016-10-20 10:06:17

simple question : get an idea with O(n)
use printf , scanf in c++
O(n) with cin , cout gives tle

Last edit: 2016-10-20 10:07:55
sas1905: 2016-10-10 12:14:00

Nice Problem.Problem Statement could have been explained in a better way though..!!

vaibhav goyal: 2016-08-18 09:17:19

@mayanksat fast i/o not required i got ac with cin/cout :D

buttman: 2016-08-11 15:25:21

use fastinput.


Added by:david_8k
Date:2012-01-14
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own problem