Loading...

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

arnold avatar arnold 50 Точки

More Exercise: Associative Arrays - задача Ranking ( вариант за решаването й)?

Здравейте, имам един въпрос относно тази задача или по-скоро търся съвет. От часове се опитвам да измисля алгоритъм за решаването й, но понеже не сме учили във Фундаменталс речник в речник, а колкото и да я мисля, не се сещам по какъв друг начин може да се реши. Да се опитвам ли да я решавам с вложен речник или има друг вариант на ниво материала от Фундаменталс, който на мен не ми идва на акъл?

 

 

https://judge.softuni.bg/Contests/Practice/Index/1302#0

More Exercise: Associative Arrays

Problems for exercise and homework for the "C#  Fundamentals" course @ SoftUni
You can check your solutions in Judge

1.Ranking

Here comes the final and the most interesting part – the Final ranking of the candidate-interns. The final ranking is determined by the points of the interview tasks and from the exams in SoftUni. Here is your final task. You will receive some lines of input in the format “{contest}:{password for contest}” until you receive “end of contests”. Save that data because you will need it later. After that you will receive other type of inputs in format “{contest}=>{password}=>{username}=>{points}” until you receive “end of submissions”. Here is what you need to do.

  • Check if the contest is valid (if you received it in the first type of input)
  • Check if the password is correct for the given contest
  • Save the user with the contest they take part in (a user can take part in many contests) and the points the user has in the given contest. If you receive the same contest and the same user update the points only if the new ones are more than the older ones.

At the end you have to print the info for the user with the most points in the format “Best candidate is {user} with total {total points} points.”. After that print all students ordered by their names. For each user print each contest with the points in descending order. See the examples.

Input

  • strings in format “{contest}:{password for contest}” until the “end of contests” command. There will be no case with two equal contests
  • strings in format “{contest}=>{password}=>{username}=>{points}” until the “end of submissions” command.
  • There will be no case with 2 or more users with same total points!

Output

  • On the first line print the best user in format “Best candidate is {user} with total {total points} points.”.
  • Then print all students ordered as mentioned above in format:

{user1 name}

#  {contest1} -> {points}

#  {contest2} -> {points}

Constraints

  • the strings may contain any ASCII character except from (:, =, >)
  • the numbers will be in range [0 - 10000]
  • second input is always valid

Examples

Input

Output

Part One Interview:success

Js Fundamentals:Peter

C# Fundamentals:fundPass

Algorithms:fun

end of contests

C# Fundamentals=>fundPass=>Tanya=>350

Algorithms=>fun=>Tanya=>380

Part One Interview=>success=>Nikola=>120

Java Basics Exam=>pesho=>PeterPeter=>400

Part One Interview=>success=>Tanya=>220

OOP Advanced=>password123=>JohnJohn=>231

C# Fundamentals=>fundPass=>Tanya=>250

C# Fundamentals=>fundPass=>Nikola=>200

Js Fundamentals=>Peter=>Tanya=>400

end of submissions

Best candidate is Tanya with total 1350 points.

Ranking:

Nikola

#  C# Fundamentals -> 200

#  Part One Interview -> 120

Tanya

#  Js Fundamentals -> 400

#  Algorithms -> 380

#  C# Fundamentals -> 350

#  Part One Interview -> 220

Java Advanced:funpass

Part Two Interview:success

Math Concept:asdasd

Java Web Basics:forrF

end of contests

Math Concept=>ispass=>Monika=>290

Java Advanced=>funpass=>Simona=>400

Part Two Interview=>success=>Dany=>120

Java Advanced=>funpass=>Peter=>90

Java Web Basics=>forrF=>Simona=>280

Part Two Interview=>success=>Peter=>0

Math Concept=>asdasd=>Dany=>250

Part Two Interview=>success=>Simona=>200

end of submissions

Best candidate is Simona with total 880 points.

Ranking:

Dany

#  Math Concept -> 250

#  Part Two Interview -> 120

Peter

#  Java Advanced -> 90

#  Part Two Interview -> 0

Simona

#  Java Advanced -> 400

#  Java Web Basics -> 280

#  Part Two Interview -> 200

0
Fundamentals Module 13/08/2021 11:35:19
svephoto avatar svephoto 1191 Точки

Здравей, arnold,

 

Без да съм решавал конкретната задача досега, според мен няма никакъв проблем ти да се опиташ да я решиш както и чрез каквото можеш. Това, че във Фундаменталс не сте учили конкретно речник в речник, не бива да те спира и ограничава. Добре дошли са всякакви работещи методи и начини за решаване на даден проблем, и търсенето на възможни варианти за решение, които не са специално изучавани, дори се насърчават. Има нужда и от голяма доза самообучение и експериментиране. cool Така че: давай смело напред с решаването според твоите лични възможности и умения, които имаш към момента. laugh

1
12/08/2021 21:19:16
arnold avatar arnold 50 Точки

След почти 15 часово решаване, успях да я измисля и с малко търсене в интернет за сортировките, но много трудно беше да си пречупя мисленето за задача с вложен речник, досега най-много до лист/масив в речника съм решавал, но това с речник речника направо ме хвърли в шах :D

 

https://pastebin.com/BhFzCMiy

1
13/08/2021 12:13:36
svephoto avatar svephoto 1191 Точки

Браво за труда, усилията и вярното решение! yes laugh Всичко това ще ти бъде от голяма полза занапред.

1
13/08/2021 12:38:45
arnold avatar arnold 50 Точки

Дано, благодаря yes

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