+ Нов въпрос
Reazer987 0 Точки

## 01.Masterchef

Здравейте! Дава ми 66/100 и не знам къде ми е грешката

ero го кода ->https://pastebin.com/hUbMcygR

Условието----->

Do you believe you have what it takes to become the new Masterchef? For tonight’s challenge you have to use the ingredients in your basket to prepare 4 excellent dishes.

First you will receive a sequence of integers, representing the number of ingredients in a single basket. After that you will be given another sequence of integers - the freshness level of the ingredients.

Your task is to cook them so you can impress the judges. The names of the dishes are listed in the table below with the exact freshness level.

 Dish Freshness Level needed Dipping sauce 150 Green salad 250 Chocolate cake 300 Lobster 400

To cook a dish, you have to take the first ingredient value and the last freshness level value. The total freshness level is calculated by their multiplication.

• If the product of this operation equals one of the levels described in the table, you make the dish and remove both ingredient and freshness value.
• Otherwise you should remove the freshness level, then increase the ingredient value by 5
• Remove the ingredient from the collection and add it again in last place, already increased by 5.
• In case you have an ingredient with value 0 you have to remove it and continue cooking.

You need to stop cooking only when you run out of ingredients or freshness level values.

Your task is considered successful if you make at least four dishes - one of each type.

## 1.Input

• The first line of input will represent the ingredients' values - integers, separated by single space
• On the second line you will be given the freshness values - integers again, separated by single space

## 2.Output

• On the first line of output - print if you've succeeded in preparing the dishes
• "Applause! The judges are fascinated by your dishes!"
• "You were voted off. Better luck next year."
• On the next output line - print the sum of the ingredients only if they are left any in the format: " Ingredients left: {ingridientsSum}"
• On the last few lines you have to print the dishes you have made ordered alphabetically, but only the ones that were made at least once in the format:
• {dish name} --> {amount}"

## 3.Constraints

• All of the ingredients' values and freshness level values will be integers in range [0, 100]
• We can have more than one cooked dish of the types specified in the table above

## 4.Examples

 Input Output Comment 10 10 12 8 10 12 25 15 50 25 25 15 Applause! The judges are fascinated by your dishes!  # Chocolate cake --> 2  # Dipping sauce --> 2  # Green salad --> 1  # Lobster --> 1 First you take the first ingredient and the last freshness level value and multiply them - the result is 150 so we make Dipping sauce. Next we have product of 250 and the Green salad is ready. Then we cook the Chocolate cake by multiplying 12 and 25. The product of next ingredient value and freshness level value is 400 and we make Lobster. Next pair is 10 and 15, we multiply them and make one more Dipping sauce. The last multiplication of 12 and 25 equals 300 and we make one more Chocolate cake. There are no more ingredients and freshness values so we stop cooking, but we have one of each dish types and print the proper message. 12 20 0 6 19 12 12 25 You were voted off. Better luck next year. Ingredients left: 55  # Chocolate cake --> 1 The first pair is 12 and 25, we cook Chocolate cake and remove both of them. Next we take 20 and 12 - the product is 240 - we can't cook any meal, so we remove the freshness level value, increase the ingredient value with 5 and add it back in last place. The next ingredient has value 0 - we remove it and continue. The next pair is 6 and 12 - again we can't make anything. After that we don't have more freshness level values, so we stop cooking. The rest of the ingredients are 19, 25, 11 with sum of 55.
Тагове:
0
icowwww 1678 Точки

Здравей,

В условието пише

On the next output line - print the sum of the ingredients only if they are left any in the format: " Ingredients left: {ingridientsSum}"

При теб ако не са събрани принтираш това безусловно, а ако са събрани въобще не принтираш

Трябва да има по едно условие в тези два случая дали сумата не е например равна на нула:

https://pastebin.com/YqxZ4xHz

0
Reazer987 0 Точки

Аа да ясно, благодаря много 😀

0