Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Siva is very busy with work and wants to order food from Zomato. He wants to order one time
- today, and buy three items costing X1, X2 and X3 rupees. He'll also order once tomorrow, where
- he'll buy three items costing Y1, Y2 and Y3 rupees. There is an additional delivery charge of
- rupees “A” on each order. He also notices that there is a coupon on sale, which costs
- rupees “C”. If he buys that coupon, the delivery charges on any day and on an order of ₹150 or
- more shall be waived (that is, the “A” rupees will not be added, if the sum of the costs of the
- items is ≥150). So Siva is ordering three items together on each day, so the delivery charge
- apply only once each day. Also, it's only needed to buy that coupon once to benefit the delivery
- fee waiver on both days. Should Siva go ahead and buy the coupon?
- Note that Shiva will buy the coupon only if it costs him strictly less than what it costs him
- without the coupon, in total.
- Input:
- The first line of the input contains a single integer T, denoting the number of test cases.
- The first line of each test case contains two space-separated integers “A” and “C”, denoting
- the delivery charge and price of the coupon.
- The second line of each test case contains three space-separated integers X1, X2 and X3,
- denoting the prices of the food items to order on Day 1.
- The third line of each test case contains three space-separated integers Y1, Y2 and Y3, denoting
- the prices of the food items to order on Day 2.
- Output: For each test case, output YES if Siva should buy the coupon, or NO otherwise.*/
- /*aLSO available on Pastebin.com*/
- /*Input
- 2
- 47 55
- 75 78 18
- 72 50 10
- 45 65
- 130 100 80
- 100 80 50
- Output
- NO
- YES*/
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- { int test_case,a,c,x1,x2,x3,y1,y2,y3;
- int day1_sum,day2_sum;
- printf("Enter number of test cases: \n");
- scanf("%d",&test_case);
- while(test_case)
- {
- start: //jump level for goto
- if(test_case == 0)
- break;
- test_case--;
- printf("\nEnter the value of 'A' & 'C' according to question: ");
- scanf("%d %d",&a,&c);
- printf("\nEnter price of all 3 food of day 1: \n");
- scanf("%d %d %d",&x1,&x2,&x3);
- printf("\nEnter price of all 3 food of day 2: \n");
- scanf("%d %d %d",&y1,&y2,&y3);
- day1_sum = x1+x2+x3;
- day2_sum = y1+y2+y3;
- if(day1_sum < 150 && day2_sum < 150)
- {
- printf("\nNO");
- goto start;
- }
- else if(day1_sum >= 150 && day2_sum >= 150)
- {
- if(c < 2*a)
- {
- printf("\nYES");
- goto start;
- }
- else
- {
- printf("\nNO");
- goto start;
- }
- }
- else
- {
- if(c<a)
- {
- printf("\nYES");
- goto start;
- }
- else
- {
- printf("\nNO");
- goto start;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement