Computer Science, asked by gokulparupalli4679, 1 month ago

A lockdown has been put in place due to the pandemic.

You cannot step out to buy food, however you can have food delivered to you.

You can purchase any amount of food in one delivery.

There is a constant delivery fee for every delivery, regardless of the amount of food purchased in the delivery.

Each type of food on the menu has two properties: a price-per-meal, and freshness-time.

One "meal" of food will feed you for one day; once a meal has been eaten, it cannot be eaten again.

The freshness-time of a type of food is the maximum number of days for which that food can still be eaten, counting from when you received it.

A freshness-time of zero means you must eat that type of food on the day of delivery.
In a single delivery you can purchase as many different types of food, and as many meals of each of those types, as you have money for.

The food will be delivered on the same day that you purchased it, and you will eat one of the food on the same day.

Food delivery is the only way for you to receive food.

Given an amount of money, which you can spend on meal prices and delivery fees,

what is the maximum number of days for which you can eat food every day - counting from the day which you order?

Input
Each test case will begin with three integers, A, B and C, denoting the amount of money you have, the delivery fee, and the number of types of food provided by the restaurant, respectively. C lines follow, each will consist of two integers, Pi and Fi, denoting respectively the price-per-meal and freshness-time of one type of food

Output
Number of days you will eat food

Sample Input
32 5 2

5 0

10 2

Sample Output
3

Answers

Answered by nikitabyadav09
5

Answer:

sorry

Explanation:

I did not understand.

Answered by shilpa85475
5

Each test case will begin with three integers, A, B and C, denoting the amount of money you have,

the delivery fee,

and the number of types of food provided by the restaurant, respectively. C lines follow, each will consist of two integers, Pi and Fi, denoting respectively the price-per-meal and freshness-time of one type of food

Explanation:

#include <bits/stdc++.h>

#define ll long long

using namespace std;

int main() {

ios_base::sync_with_stdio(false);

cin.tie(NULL);

cout.tie(NULL);

 

int t;

cin >> t;

 

while(t--){

   int c,d;

   cin >> d >> c;

   int a1,a2,a3,b1,b2,b3,sumA=0,sumB=0;

   cin >> a1 >> a2 >> a3;

   cin >> b1 >> b2 >> b3;

   sumA = a1 + a2 + a3;

   sumB = b1 + b2 + b3;

   

   if(sumA>=150 && sumB>=150)

   {

       if((sumA+sumB+c)<(sumA+sumB+ 2*d))

       {

           cout << "YES" << endl;

       }

       else

        cout <<"NO"<<endl;

   }

   else if(sumA>=150 || sumB>=150)

   {

       if((sumA+sumB+ c + d)<(sumA+sumB+ 2*d))

       {

           cout << "YES" << endl;

       }

       else

        cout <<"NO"<<endl;

   }

   else

        cout <<"NO"<<endl;

}

return 0;

}

Similar questions