Loading...
Victor_Atanasov avatar Victor_Atanasov 1 Точки

01.MasterChef

Здравейте, judge ми дава 66/100 и не знам къде ми е грешката.

Кода ми - https://pastebin.pl/view/74a232f3

Условие ->

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.

Тагове:
1
C# Advanced
kace123 avatar kace123 3 Точки

Здравей грешка едно според мен беше от ред 21-39, излишни са тези foreach цикли, отделно имаш > 0, а трябва да е >= 0. След което в условието има, че ако имаш ingredient със стойност 0, трябва да го премахнеш и да продължиш. При теб никога няма да има ingredient 0, защото по рано във foreach си написал > 0.

  • In case you have an ingredient with value 0 you have to remove it and continue cooking.

Прилагам редактирания ти код, с който имам 100 точки: https://pastebin.com/zTqwFTM6

 

1
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.