(C++ ARRAYS TASK!) The transport company transports cargo from Vilnius to Klaipeda. Manufacturers load goods into containers. Only products from one manufacturer are loaded in one container. There may be incomplete containers. The goods of a particular manufacturer are loaded into the container until they are exhausted or the container is filled. Products of all manufacturers are the same size (i.e. the container holds the same amount of products). Develop a program that calculates the minimum number of containers needed for all products and determines how many of these containers will be filled. For example, if a container holds 6 products, you will need to find how many containers will be needed, several containers will be filled (6 products), five products will be on the roads, four, three, two on the roads and only one product on the roads. The original data is saved in a text file. The first line contains two integers: the number of producers n (1
Containers (C++ ARRAYS TASK!)
The transport company transports cargo from Vilnius to Klaipeda. Manufacturers load goods into containers. Only products from one manufacturer are loaded in one container. There may be incomplete containers. The goods of a particular manufacturer are loaded into the container until they are exhausted or the container is filled.
Products of all manufacturers are the same size (i.e. the container holds the same amount of products).
Develop a
For example, if a container holds 6 products, you will need to find how many containers will be needed, several containers will be filled (6 products), five products will be on the roads, four, three, two on the roads and only one product on the roads.
The original data is saved in a text file. The first line contains two integers: the number of producers n (1 <n <1000) and the container capacity (1 <g <100). The following n lines record how many products each manufacturer wants to take to Klaipeda. These are integers from 1 to 1000.
The results are saved in a text file. The first line must indicate the number of containers that will be needed to transport all the products. In the following lines, the numbers of containers must be listed in descending order of the quantity of products in the containers.
______________________________________________
(Explanation that couldn't fit in the image)
There is 1 manufacturer, one container holds 5 products, 26 products need to be transported
This will require 6 containers, of which 5 will be completely filled (i.e. they will contain 5 products each) and 1 container will be half empty - it will contain only 1 product.
Step by step
Solved in 2 steps