#C8122. Normalize Waveform
Normalize Waveform
Normalize Waveform
You are given an audio waveform encoded as a space-separated string of triplets. Each triplet contains a value, a frequency, and a duration in that order. Your task is to normalize the waveform by replacing each value with the average of its neighbors and itself. Specifically, for a waveform with n triplets:
- If n = 1, the waveform remains unchanged.
- For the first triplet the new value is the average of the first and second values.
- For the last triplet the new value is the average of the last and the penultimate values.
- For any middle triplet, the new value is the average of the previous, current, and next values.
Note: Use integer division (floor division) when computing averages. All formulas are given in \(\LaTeX\) format. For example, the first element's new value is computed as \(\lfloor \frac{v_1+v_2}{2}\rfloor\) and a middle element as \(\lfloor \frac{v_{i-1}+v_i+v_{i+1}}{3}\rfloor\).
inputFormat
The input is provided via standard input (stdin) as a single line containing space-separated integers representing the waveform triplets. Each triplet is of the form: value frequency duration
.
outputFormat
The output, printed to standard output (stdout), should be the normalized waveform in the same triplet format. The values must be updated as per the normalization rule described above.
## sample10 440 1
10 440 1