Get a guaranteed software dev job of ₹5-40 LPA | Apply now for free!

Wipro NLTH Coding Solve | Special Discount |

An e –commerce company is planning to give a special discount on all its product to its customers for the Christmas holiday. The company possesses data on its stock of N product types. The data for each product type represents the count of customers who have ordered the given product. If the data K is positive then it shows that the product has been ordered by K customers and is in stock. If the data K is negative then it shows that it has been ordered by K customers but is not in stock. The company will fulfill the order directly if the ordered product is in stock. If it is not in stock, then the company will fulfill the order after they replenish the stock from the warehouse. They are planning to offer a discount amount A for each product. The discount value will be distributed to the customers who have purchased that selected product. The discount will be distributed only if the decided amount A con be divided by the number of orders for a particular product. Write an algorithm for the sales team to find the number of products out of N for which the discount will be distributed.

The first line of the input consists of two space-separated integers – numOfProducts and disAmount, representing the number of different types of products (N) and the discount amount that will be distributed among the customers. Order N representing the current status of the stock for the orders of the respective product types.

Print an integer representing the number of products out of N for which the discount will be distributed.

0 ≤ numOfProducts, disAmount ≤105
-106 ≤ order i ≤106
0≤ i ≤ numOfProducts


7 18
9 -3 8 -7 -8 18 10


The product for which the number of customers will collect the discount amount “18” are for product types 0 and 5, i.e. 9 and 18, respectively. So, the output is 2

int main()
    int n,i,dis,c=0;
    scanf("%d %d",&n,&dis);
    int order[n];
        if(order[i]>0 && dis%order[i]==0)

Also Checkout

Recent Posts