Thread: Please help me in solving this problem using C language!!

  1. #1
    Registered User
    Join Date
    Nov 2017
    Posts
    34

    Unhappy Please help me in solving this problem using C language!!

    In Chefland, there is a very famous street where N types of street food (numbered 1 through N) are offered. For each valid i, there are Si stores that offer food of thei-th type, the price of one piece of food of this type is Vi(the same in each of these stores) and each day, Pi people come to buy it; each of these people wants to buy one piece of food of the i-th type.


    Chef is planning to open a new store at this street, where he would offer food of one of these N

    types. Chef assumes that the people who want to buy the type of food he'd offer will split equally among all stores that offer it, and if this is impossible, i.e. the number of these people p is not divisible by the number of these stores s, then only [p/s] people will buy food from Chef.

    Chef wants to maximise his daily profit. Help Chef choose which type of food to offer and find the maximum daily profit he can make.

    Input

    1.The first line of the input contains a single integer T
    denoting the number of test cases.

    2.The description of T lines follow. For each i (1iN),


    3.the i-th of these lines contains three space-separated integers Si, Pi and Vi.
    Output

    For each test case, print a single line containing one integer ― the maximum profit.

    Constraints:


    • 1T100
    • 1N100
    • 1Si,Vi,Pi10,000 for each valid i

    Example Input

    2
    3
    4 6 8
    2 6 6
    1 4 3
    1
    7 7 4
    Example Output

    12
    0
    Explanation

    Example case 1: Chef should offer food of the second type. On each day, two people would buy from him, so his daily profit would be 12

    .
    Example case 2: Chef has no option other than to offer the only type of food, but he does not expect anyone to buy from him anyway, so his daily profit is 0


  2. #2
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    887
    Dude at least try to make it look like its not taken directly from a textbook, anyways the tasks are there for you to LEARN from, posting code you already made to get help bug fixing is fine but fobbing off the entirety of the task without even trying to do it yourself is just shooting yourself in the foot.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,059
    The last thing we need here are a stream of codechef wannabies dumping their zero effort homework.

    @OP, start a new thread with some actual code of your own if you want to learn something.
    And no, code you "find" using google won't count, and we can usually tell.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 01-06-2013, 07:49 AM
  2. Simplifying Numerical Solving before actual solving
    By Vespasian in forum Tech Board
    Replies: 3
    Last Post: 10-14-2012, 11:39 AM
  3. Help with solving this problem
    By Neox in forum C++ Programming
    Replies: 5
    Last Post: 11-20-2010, 03:40 PM
  4. Solving A Maze Using C Language!!!!
    By jonnybgood in forum C Programming
    Replies: 6
    Last Post: 11-08-2005, 12:15 PM
  5. C++ problem solving, HELP....PLEASE
    By Dana in forum C++ Programming
    Replies: 3
    Last Post: 09-25-2001, 04:05 PM

Tags for this Thread