atcoder#AGC028C. [AGC028C] Min Cost Cycle
[AGC028C] Min Cost Cycle
Score : points
Problem Statement
We have a directed weighted graph with vertices. Each vertex has two integers written on it, and the integers written on Vertex are and .
In this graph, there is an edge from Vertex to Vertex for all pairs , and its weight is .
We will consider a directed cycle in this graph that visits every vertex exactly once. Find the minimum total weight of the edges in such a cycle.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum total weight of the edges in such a cycle.
3
1 5
4 2
6 3
7
Consider the cycle . The weights of those edges are , and , for a total of . As there is no cycle with a total weight of less than , the answer is .
4
1 5
2 6
3 7
4 8
10
6
19 92
64 64
78 48
57 33
73 6
95 73
227