Find the first step in [30.0, 30.2], then report 30.0 minus the smallest position among steps at least 3 later, or 0 if none exists.
Easy2ImplementationArrayInterviewNo attempts yetTime limit2sMemory limit512 MBThe triple jump is a track and field event where you take a runup and then jump three times in a row. The recorded distance runs from the start of the first jump to the end of the third jump. As in the long jump, the first jump must start from a designated take off board. Falling backwards after you land costs you distance, because the measurement stops at the nearest imprint your body leaves in the sand. If you land on your feet and then tip back onto your butt, the distance to that butt imprint is what counts.
In this problem you are given the positions where parts of your body touched the ground, in order. The take off board runs from 30.0 to 30.2, endpoints included. Positions can grow or shrink, because you may turn back or fall backwards.
The triple jump starts at the first step whose position lies inside the interval [30.0,30.2]. The distance is measured from 30.0, not from the position actually touched, to the smallest position among the steps that come at least 3 steps after the starting step. This distance can be negative. If no step lands inside the interval, or you take fewer than 3 more steps after the starting step, the distance counts as 0.
The first line contains the number of data sets K. Then K data sets follow, each in this form.
The first line of a data set contains the number of steps n (1≤n≤1000). The next line contains n real numbers x1,x2,…,xn (0.0≤xi≤100.0). xi is the position where you touched the track or the sandbox on step i.
For each data set, print Data Set x: on a line of its own, where x is the number of the data set counting from 1. On the next line print the triple jump distance rounded to two decimals. Round a value that sits exactly halfway away from zero, and print 0.00 without a sign when the rounded value is zero. Print one blank line after each data set.