Tagged: ,

  • Maximum Sum of Building Speed….

  • Akash 

    Administrator
    at

    Maximum Sum of Building Speed

    You are the king of Pennsville where you have 2N workers.

    All workers will be grouped in the association of size 2, so a total of N associations have to be formed.

    The building speed of the ith worker is Ai.

    To make an association, you pick up 2N workers. Let the minimum building speed between both workers be x, then the association has the resultant building speed x.

    You have to print the maximum value possible of the sum of building speeds of N associations if you make the associations optimally.

    Constraints
    1≤N≤5∗10 ^4

    1≤Ai≤10^4

    Input

    First-line contains an integer N, representing the number of associations to be made.

    The next line contains 2N space-separated integers, denoting the building speeds of 2N workers.

    Output

    Print the maximum value possible of the sum of building speeds of all the associations.

    Sample Input

    2

    1 3 1 2

    Sample Output

    3

Log in to reply.

Original Post
0 of 0 posts June 2018
Now
KodNest Training New Batch is starting on 19th October 2020. Attend one week free demo classes.Register Now

New Report

Close