| 2026 Spring UT CS104c Midterm #2 |
|---|
| Finished |
You are a researcher at Chime Labs, a premier private-sector facility operating under the wing of a major telecommunications giant. The fiscal year is ending, the market is down, and your department is facing massive layoffs. To save your career, you have "discovered" a revolutionary copper wire formulation that supposedly eliminates signal noise.
According to your falsified white paper, a series of electrical signals $$$e_1, e_2, \dots, e_n$$$ is considered "perfectly clean" if it follows a strict alternating pattern. Specifically, the signals must satisfy one of the following two conditions:
The issue is that your actual prototype produces a standard, noisy signal that doesn't follow these rules. To maintain the facade during the live demonstration for the board of directors, you intend to manually calibrate the equipment. You can perform a single type of operation: select any signal $$$i$$$ and decrease the value of $$$e_i$$$ by 1. You can perform this operation as many times as you like on the same $$$i$$$, and you may perform it on any number of different $$$i$$$.
Because the board is watching closely, you want to minimize the total number of operations performed so the adjustments aren't noticed. Find the minimum number of operations required to transform the initial signal into a "perfectly clean" one.
The first line contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$, representing the number of signals recorded. The second line contains $$$n$$$ space-separated integers $$$e_1, e_2, \dots, e_n$$$ $$$(1 \le e_i \le 10^7)$$$, representing the initial values of the signals.
Print a single integer, the minimum number of operations required to make the signal clean.
58 2 10 10 8
3
| Name |
|---|


