F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Perfect matching

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 786    Accepted Submission(s): 209


Problem Description
Given the complete bipartite graph. Each part of this graph has N vertices, i.e. the graph is balanced. An integer number (called a weight) assigns to each vertex. The weight of the edge is defined as the product of weights of vertices which connected by this edge.
It is well known, a matching in a graph is a set of edges without common vertices. A matching is perfect, if it covers all vertices of a graph.
Write a program to find a perfect match of the given bipartite graph with the maximal weight of the matching edges minimal.
 

Input
The input consists of multiple cases.
For each testcase,there will be exactly three lines;
The first line contains one integer number N (1 ¡Ü N ¡Ü 105). The second line consist of N integer numbers, not exceeded 109 by absolute value. The i-th number in line denotes a weight of i-th vertex of first part of a graph. In the third line, weights of vertices of second part are presented.

 

Output
The answer specified above.
 

Sample Input
3 1 2 3 9 10 11
 

Sample Output
27
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-11 16:54:07, Gzip enabled