1298: 实验2-2-1 心率序列统计的动态数组与vector实现 / Heart Rate Statistics with Dynamic Array and vector
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:171
Solved:142
Description
【中文题面】
本题延续实验2-1题目1。输入一组心率数据,输出最大值、最小值、平均值和异常变化次数。异常变化指相邻两次心率差的绝对值大于等于20。
课堂要求:本题在同一个OJ题目中提交两种solution:第一种使用new[]/delete[]保存心率序列,第二种使用vector保存心率序列。两种solution的输出必须完全一致。调试记录中需要比较两种实现的主要改动行、运行时间和内存使用。
[English Statement]
This problem continues Problem 1 from Experiment 2-1. Given a heart-rate sequence, output the maximum value, minimum value, average value, and the abnormal-change count. An abnormal change means the absolute difference between two adjacent values is at least 20.
Class requirement: submit two solutions to the same OJ problem. The first solution should use new[]/delete[] to store the sequence, and the second should use vector. The outputs must be identical. In the debug record, compare the main changed lines, runtime, and memory use of the two implementations.
本题延续实验2-1题目1。输入一组心率数据,输出最大值、最小值、平均值和异常变化次数。异常变化指相邻两次心率差的绝对值大于等于20。
课堂要求:本题在同一个OJ题目中提交两种solution:第一种使用new[]/delete[]保存心率序列,第二种使用vector
[English Statement]
This problem continues Problem 1 from Experiment 2-1. Given a heart-rate sequence, output the maximum value, minimum value, average value, and the abnormal-change count. An abnormal change means the absolute difference between two adjacent values is at least 20.
Class requirement: submit two solutions to the same OJ problem. The first solution should use new[]/delete[] to store the sequence, and the second should use vector
Input
【输入】
第一行输入整数n。第二行输入n个整数,表示心率序列。数据保证1<=n<=100000。
[Input]
The first line contains n. The second line contains n integers representing the heart-rate sequence. It is guaranteed that 1<=n<=100000.
第一行输入整数n。第二行输入n个整数,表示心率序列。数据保证1<=n<=100000。
[Input]
The first line contains n. The second line contains n integers representing the heart-rate sequence. It is guaranteed that 1<=n<=100000.
Output
【输出】
第一行输出最大值、最小值和平均值,平均值保留1位小数。第二行输出异常变化次数。
[Output]
Print the maximum value, minimum value, and average rounded to 1 decimal place on the first line. Print the abnormal-change count on the second line.
第一行输出最大值、最小值和平均值,平均值保留1位小数。第二行输出异常变化次数。
[Output]
Print the maximum value, minimum value, and average rounded to 1 decimal place on the first line. Print the abnormal-change count on the second line.
Sample Input Copy
6
72 75 98 101 80 79
Sample Output Copy
101 72 84.2
2
HINT
建议先从实验2-1的固定数组版本改成new/delete版本,再改成vector版本。重点观察哪些行只是存储方式变化,哪些行是统计逻辑。
Start from the fixed-array version in Experiment 2-1, then modify it to the new/delete version and the vector version. Focus on which lines are only storage changes and which lines are the statistical logic.
Start from the fixed-array version in Experiment 2-1, then modify it to the new/delete version and the vector version. Focus on which lines are only storage changes and which lines are the statistical logic.