dominique11 dipierro
Repovive Pre-Opening Contest/ Discussion
December 2, 2025 • 2 min read • 1 views
1A. Magical Stones
Just sort both arrays and then take the absolute sum of the differences between corresponding elements. This is optimal because any swap from this configuration will only increase the cost.
1B. Sweet Gifts
Iterate through every subarray in O(n^2). Within the loop, keep track of the frequency using a count[] array and its maximum value using an mx variable.
1C. Rayan's Journey
We have a graph composed of sparse roads and dense teleport-devices. We can model the dense edges using pseudo nodes for every type. A pseudo node of type t will only be joined with nodes of type t in such a way that:
- The incoming edge from any node of type
twill have zero weight. - The outgoing edge from the pseudo node will have weight
C_t, and it will be connected to every node of the same type.
This construction results in m+2n edges and 2n nodes. We can then use Dijkstra's algorithm to find the shortest path.
1D. Stone Piles
?
1E. Two Paths
?