From bbbe52ee59dca8dee005a44f4dee37f92cd27ae7 Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Fri, 20 Sep 2024 12:32:38 -0300 Subject: [PATCH] =?UTF-8?q?Solve=20Barbecue=20at=20Yuri=E2=80=99s=20in=20p?= =?UTF-8?q?ython?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solutions/beecrowd/2633/2633.py | 23 +++++++++++++++++++++++ solutions/beecrowd/2633/in.txt | 9 +++++++++ solutions/beecrowd/2633/out.txt | 2 ++ solutions/beecrowd/2633/problem.md | 30 ++++++++++++++++++++++++++++++ solutions/beecrowd/2633/tags.txt | 1 + 5 files changed, 65 insertions(+) create mode 100644 solutions/beecrowd/2633/2633.py create mode 100644 solutions/beecrowd/2633/in.txt create mode 100644 solutions/beecrowd/2633/out.txt create mode 100644 solutions/beecrowd/2633/problem.md create mode 100644 solutions/beecrowd/2633/tags.txt diff --git a/solutions/beecrowd/2633/2633.py b/solutions/beecrowd/2633/2633.py new file mode 100644 index 00000000..09f9c161 --- /dev/null +++ b/solutions/beecrowd/2633/2633.py @@ -0,0 +1,23 @@ +import heapq +import sys + +for line in sys.stdin: + n = int(line) + + if not line: + break + + sorted_ingredients = [] + + for _ in range(n): + ingredient, days_until_expire = input().split() + days_until_expire = int(days_until_expire) + + heapq.heappush(sorted_ingredients, (days_until_expire, ingredient)) + + for i in range(n): + if i > 0 and i < n: + print(" ", end="") + print(heapq.heappop(sorted_ingredients)[1], end="") + + print() diff --git a/solutions/beecrowd/2633/in.txt b/solutions/beecrowd/2633/in.txt new file mode 100644 index 00000000..432703f6 --- /dev/null +++ b/solutions/beecrowd/2633/in.txt @@ -0,0 +1,9 @@ +3 +picanha 15 +coracao 14 +maminha 37 +4 +alcatra 17 +linguica 13 +asinha 5 +pernil 23 diff --git a/solutions/beecrowd/2633/out.txt b/solutions/beecrowd/2633/out.txt new file mode 100644 index 00000000..10c33818 --- /dev/null +++ b/solutions/beecrowd/2633/out.txt @@ -0,0 +1,2 @@ +coracao picanha maminha +asinha linguica alcatra pernil diff --git a/solutions/beecrowd/2633/problem.md b/solutions/beecrowd/2633/problem.md new file mode 100644 index 00000000..b549cff2 --- /dev/null +++ b/solutions/beecrowd/2633/problem.md @@ -0,0 +1,30 @@ +https://judge.beecrowd.com/en/problems/view/2633 + +# Barbecue at Yuri’s + +Yuri is a good friend. We always do the "brothers' barbecue ;)" at his house! +This time, the reason for the barbecue is that the brothers are finally starting +to pass on good contests! So today we'll have a special edition of barbecue, +with alcohol and soap soccer! + +The soap soccer company is taking a long time to fill the field and Yuri, +already bored, began to get distracted on the following question: if we baked +the meat by the expiration date, what would be the resulting sequence of meat +pieces? Since Yuri's MacBook is too far away (and laziness is too close), he +asked for your help in answering this question. + +## Input + +The input is made up of several test cases and ends with and enf of file. The +first line of a test case contains an integer $N (0 \leq N \leq 10)$, which is +the number of pieces of meat from today's barbecue. Then there will be $N$ +lines, each with a string of maximum 20 characters, with only characters from +'a' to 'z', and an integer $D^i (0 \leq D^i \leq 50)$ representing the +expiration date of the $i$-th piece. Yuri decided to collaborate and calculate +at least this $D^i$ number of days until the expiration date, from today, of each +piece of meat. It is guaranteed that if $i \neq j$, then $D^i \neq D^j$. + +## Output + +For each test case, print a single line with the sequence of pieces of meat that +Yuri wants to calculate. Each piece must be separated by a single space. diff --git a/solutions/beecrowd/2633/tags.txt b/solutions/beecrowd/2633/tags.txt new file mode 100644 index 00000000..cfd453e8 --- /dev/null +++ b/solutions/beecrowd/2633/tags.txt @@ -0,0 +1 @@ +data structures and libraries