Skip to content

Commit

Permalink
Solve Barbecue at Yuri’s in python
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Sep 20, 2024
1 parent a8898e7 commit bbbe52e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
23 changes: 23 additions & 0 deletions solutions/beecrowd/2633/2633.py
Original file line number Diff line number Diff line change
@@ -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()
9 changes: 9 additions & 0 deletions solutions/beecrowd/2633/in.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
3
picanha 15
coracao 14
maminha 37
4
alcatra 17
linguica 13
asinha 5
pernil 23
2 changes: 2 additions & 0 deletions solutions/beecrowd/2633/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coracao picanha maminha
asinha linguica alcatra pernil
30 changes: 30 additions & 0 deletions solutions/beecrowd/2633/problem.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions solutions/beecrowd/2633/tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data structures and libraries

0 comments on commit bbbe52e

Please sign in to comment.