#C6244. Total Hike Distance
Total Hike Distance
Total Hike Distance
You are given the number of days \(d\) and for each day, a list representing the distances of different segments of a hike. For each day, you are also provided with an integer \(k\) which tells you how many segments to sum up from the beginning of the day's list. Your task is to calculate the total distance hiked for each day by summing only the first \(k\) segments. For example, if for a day \(k = 3\) and the segments are [5, 10, 15], then the total distance for that day is \(5+10+15=30\).
Note: The list of segment distances on each day might contain more values than \(k\). In such cases, only the first \(k\) values should be considered for the sum.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \(d\) representing the number of days.
- For each day, there are two lines:
- The first line contains an integer \(k\) indicating the number of segments to count.
- The second line contains a space-separated list of integers representing the segment distances.
outputFormat
For each day, output the total distance calculated by summing the first \(k\) segments. Each result should be printed on a new line to standard output (stdout).
## sample2
3
5 10 15
2
7 14
30
21
</p>