#C3349. Temperature Variation

    ID: 46766 Type: Default 1000ms 256MiB

Temperature Variation

Temperature Variation

You are given several datasets containing daily temperature readings. Each dataset starts with an integer (d) which represents the number of days in that dataset. For each day, the first number is an integer (h) representing the number of temperature readings for that day, followed by (h) integer readings. The temperature variation of a day is defined as

[ V = \sum_{i=2}^{h} |T_i - T_{i-1}|, ]

where (T_i) is the (i)-th temperature reading. A dataset with (d = 0) indicates the end of input. Your task is to compute the temperature variation for every day in all datasets and output the results as space-separated values.

inputFormat

The input consists of a sequence of integers read from standard input. The first integer of a dataset is (d), the number of days. If (d = 0), it indicates the termination of input. For each of the following (d) days, the first integer is (h) (the number of temperature readings), followed by (h) integers representing the temperature readings for that day.

outputFormat

Output a single line containing the computed temperature variations for all days in the order they appear, separated by a single space.## sample

2 5 20 21 19 22 20 3 15 18 15 0
8 6