SP23492 QTDIVIDE - One piece
Description
One of DB and TN common interests is traveling. One day, they went to Grand Line and found One Piece !
The One Piece treasure has n gold coins (n is even). Both them like gold coins, but they evaluate them as different values. So they decided to divide those coins by following method :
DB and TN do n / 2 steps, at each step, DB choose 2 coins, TN takes the coin that she evaluates it greater, and DB take the rest coin.
Let’s help DB find how to take the maximum value at possible.
Input Format
First line : a single integer n (n is even) – the number of coins
Second line : n integers a $ _{1} $ , a $ _{2} $ , …, a $ _{n.} $ a $ _{i} $ is the value of i $ ^{th} $ coin that TN evaluates.
Third line : n integers b $ _{1} $ , b $ _{2} $ , …, b $ _{n.} $ b $ _{i} $ is the value of i $ ^{th} $ coin that DB evaluates.
Output Format
First line : an integer S – the maximum value DB can take.
Last n / 2 lines : i $ ^{th} $ line contains two number x and y (1 coins that DB choose on i $ ^{th} $ step. Each coin must be chose exact one time.
If there are multiple ways, just print any of them.