This C++ solution uses simulation for DMOJ dmopc18c4p3 Dr. Henri and Ionization. Read the reasoning, inspect the code, or try your own test case below.
Dr. Henri and Ionization gives individual and opposite-pair removal costs on a circle; the code's parity/minimum adjustment computes the required minimum total cost.
Geometry
Problem and code
Useful links.
Written by benbenyaojifen. Try the problem first, then compare your approach with the code.
Python records executed lines and locals automatically. For selected values in any language, add // @trace i, total on its own valid line; Python uses # @trace i, total.
StatusReady
Output
No run yet.
Diagnostics
No diagnostics yet.
Each run is isolated and has strict limits. Passing one test does not guarantee the judge will accept the solution.