Minimum Project Cost

Company: Ibm_20nov

Difficulty: medium

Problem Statement

Minimum Project Cost Problem Description A client has posted numProjects web-development projects, labelled 0 to numProjects - 1 . Freelancers have placed n bids. Bid i is a bid of bid[i] on project projectId[i] ; the two arrays are aligned, so projectId[i] always goes with bid[i] . The client awards each project independently to one of the freelancers who bid on it, and wants to spend as little as possible in total. Report that minimum total cost. If any project has received no bid at all, the client cannot complete every project, so report -1 . Complete the function minCost(numProjects, projectId, bid) , which returns the minimum total cost as a 64-bit integer, or -1 . Input For custom testing the input is four lines: the first line contains numProjects ; the second line contains n , the number of bids; the third line contains n integers, projectId[0] ... projectId[n-1] ; the fourth line contains n integers, bid[0] ... bid[n-1] . Output Print one integer: the minimum total cost, or -