#K10371. Taco Sequence Tasks
Taco Sequence Tasks
Taco Sequence Tasks
You are given a sequence of integers and a set of tasks. Each task involves performing an operation on the prefix of the sequence. There are three possible tasks:
- Sumprob n: Compute the sum of the first \(n\) elements.
- Maxseq n: Find the maximum value among the first \(n\) elements.
- Meanprob n: Calculate the average (arithmetic mean) of the first \(n\) elements, i.e., \( \frac{\sum_{i=1}^n a_i}{n} \).
You will be provided with a space-separated list of integers representing the sequence, followed by an integer \(t\) which indicates the number of tasks. Then, \(t\) lines follow, each containing one task in the format task_name n
.
Your program should process each task in the order given and output the result of each task on a new line. Use stdin
as input and stdout
for output.
inputFormat
The first line contains the sequence of integers separated by spaces. The second line contains an integer \(t\) indicating the number of tasks. The following \(t\) lines each contain a task in the following format:
Sumprob n
Maxseq n
Meanprob n
Each \(n\) represents the number of elements from the beginning of the sequence to be used for that task.
outputFormat
For each task, output the result on a new line. For Meanprob
, output the floating-point result without any formatting restrictions.
12 4 7 9 15
1
Sumprob 4
32
</p>