Loops – Arithmetic – Problem #11

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: Hard

Problem Statement

Consider that n number of machines in the CSE department are broken that needs to be fixed. Suppose each machine has different configuration, and the department is planning to assign each machine to an individual vendor for repairing, and there are total n number of vendors. Now each of these vendors are demanding different prices for fixing different machines. The price for each machine demanded by each vendor is put in an array. To keep things simple, consider n = 4. For example, the price list of machine1 is stored as int m1[4] = {8200, 8300, 6900, 9200}. This means for machine1, the price quote of vendor1 is 8200, vendor2 it is 8300, vendor3 it is 6900, and vendor4 it is 9200. Similarly m2[ ], m3[ ], and m4 [ ] stores the price quotations of other machines for the 4 vendors. Now the goal is to assign one machine to each vendor so that all tasks are completed with the smallest total cost. In order to do this, you have to consider all possible combinations of machines and vendors, and find the smallest cost and the corresponding combination of machine and vendor. Note that each vendor will be assigned exactly one machine. Your program should output the total cost, as well as the assigned vendors to the machines. You may initialize the arrays m1, m2, m3, and m4 in the code (no need to take user input). Example: Input: m1 → 8200, 8300, 6900, 9200 m2 → 7700, 3700, 4900, 9200 m3 → 1100, 6900, 500, 8600 m4 → 800, 900, 9800, 2300 Output: Total cost = 14000 Machine1 - Vendor3 Machine2 - Vendor2 Machine3 - Vendor1 Machine4 - Vendor4

Back to Lab Problems
Loops/Arithmetic/Problem #11

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #11

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.