agc028c
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Score : 700 points
Problem Statement
We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are Ai and Bi.
In this graph, there is an edge from Vertex x to Vertex y for all pairs 1≤x,y≤N, and its weight is min(Ax,By).
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
- 2≤N≤105
- 1≤Ai≤109
- 1≤Bi≤109
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A1 B1 A2 B2 : AN BN
Output
Print the minimum total weight of the edges in such a cycle.
Sample Input 1Copy
3 1 5 4 2 6 3
Sample Output 1Copy
7
Consider the cycle 1→3→2→1. The weights of those edges are min(A1,B3)=1, min(A3,B2)=2 and min(A2,B1)=4, for a total of 7. As there is no cycle with a total weight of less than 7, the answer is 7.
Sample Input 2Copy
4 1 5 2 6 3 7 4 8
Sample Output 2Copy
10
Sample Input 3Copy
6 19 92 64 64 78 48 57 33 73 6 95 73
Sample Output 3Copy
227
ad-hoc 选讲——liangzexian1
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 6
- Start at
- 2024-9-25 10:30
- End at
- 2024-9-28 10:30
- Duration
- 72 hour(s)
- Host
- Partic.
- 17