Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

SongArm avatar SongArm 0 Точки

Получавам 20/100 на почти решена задача и не знам как да я продължа

https://pastebin.com/hgtTVC1H

 

 

Create a program that organizes the daily feeding of animals. You need to keep information about animals, their daily food limit and the areas of the Wildlife Refuge they live in. You will be receiving lines with commands until you receive the "EndDay" message.  There are two possible commands:

  • "Add: {animalName}-{dailyFoodLimit}-{area}":
    • Add the animal and its daily food limit to your records. It is guaranteed that the names of the animals are unique and there will never be animals with the same name. If it already exists, just increase the value of the daily food limit with the current one that is given.
  • "Feed: {animalName}-{food}-{area}":
    • Check if the animal exists and if it does, reduce its daily food limit with the given food for feeding. If its limit reaches 0 or less, the animal is considered successfully fed and you need to remove it from your records and print the following message:
      • "{animalName} was successfully fed"

You need to know the count of hungry animals there are left in each area in the end. If an animal has daily food limit above 0, it is considered hungry.

In the end, you have to print each animal with its daily food limit sorted in descending order by the daily food limit and then by its name in ascending order in the following format:

Animals:

{animalName} -> {dailyFoodLimit}g

{animalName} -> {dailyFoodLimit}g

Afterwards, print the areas with the count of animals, which are not fed in descending order by the count of animals. If an area has 0 hungry animals in it, don't print it. The output must be in the following format:

Areas with hungry animals:

{areaName} : {countOfUnfedAnimals}

{areaName} : {countOfUnfedAnimals}

Input / Constraints

  • You will be receiving lines until you receive the "Last Info" command.
  • The food comes in grams and is an integer number in the range [1...100000].
  • The input will always be valid.
  • There will never be a case, in which an animal is in two or more areas at the same time.

Output

  • Print the appropriate message after the "Feed" command, if an animal is fed.
  • Print the animals with their daily food limit in the format described above.
  • Print the areas with the count of unfed animals in them in the format described above.
Тагове:
0
Java Fundamentals
svephoto avatar svephoto 1191 Точки

Здравей, SongArm,

 

Къде можем да тестваме решението на задачата, има ли контест в Judge?

0
SongArm avatar SongArm 0 Точки

В момента не е достъпен judje но ако може просто да бъде пратено някакво примерно решение . Грешката ми е в тази част

'Afterwards, print the areas with the count of animals, which are not fed in descending order by the count of animals. If an area has 0 hungry animals in it, don't print it. The output must be in the following format: '

Не знам как на Area да инкрементирам когато някое животно остане гладно в конкретната зона . Всичко друго няма проблем , но ми даде на изпита 20/100

Input

  • The possible commands are:
    • "
    • Add: {animal_name}-{needed_food_quantity}-{area}"
    • Feed: {animalName}-{food}"

Output

  • The possible outputs are:
  • "{animalName} was successfully fed"
  •  

" {animal_name} -> {needed_food_quantity}g"

  •  

" {animal_name} -> {needed_food_quantity}g"

  • "Areas with hungry animals:"

" {area_name}: {number_of_hungry_animals}"

  •  

" {area_name}: {number_of_hungry_animals}"

вход:                                                                                                                                                 

Заповядайте и входни данни !               

(["Add: Adam-4500-ByTheCreek",

"Add: Maya-7600-WaterfallArea",

"Add: Maya-1230-WaterfallArea",

"Feed: Jamie-2000",

"EndDay"])

изход:

Animals:

 Adam -> 4500g

 Maya -> 8830g

Areas with hungry animals:

 ByTheCreek: 1

 WaterfallArea: 1

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