1299: 实验2-2-2 三点中值滤波的动态数组与vector实现 / Three-Point Median Filtering with Dynamic Array and vector

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:150 Solved:141

Description

【中文题面】
本题延续实验2-1题目4。输入一段整数信号序列,进行三点中值滤波。首尾保持原值,中间位置输出左侧、当前位置、右侧三个数的中位数。
课堂要求:本题在同一个OJ题目中提交两种solution:第一种使用new[]/delete[]保存原始序列和滤波结果,第二种使用vector保存原始序列和滤波结果。两种solution的输出必须完全一致。
[English Statement]
This problem continues Problem 4 from Experiment 2-1. Given an integer signal sequence, apply three-point median filtering. The first and last values remain unchanged, and each middle position outputs the median of its left value, itself, and its right value.
Class requirement: submit two solutions to the same OJ problem. The first solution should use new[]/delete[] for the source and result arrays, and the second should use vector. The outputs must be identical.

Input

【输入】
第一行输入整数n。第二行输入n个整数,表示原始信号序列。数据保证1<=n<=100000。
[Input]
The first line contains n. The second line contains n integers representing the original signal sequence. It is guaranteed that 1<=n<=100000.

Output

【输出】
输出一行n个整数,表示滤波后的序列。
[Output]
Print one line with n integers representing the filtered sequence.

Sample Input Copy

7
80 82 200 83 84 10 85

Sample Output Copy

80 82 83 84 83 84 85

HINT

滤波时应从原始数组src读取,向结果数组dst写入。不要边读边改同一个数组。
Read from the original array src and write to the result array dst. Do not read and modify the same array during filtering.