시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 (추가 시간 없음) | 2048 MB | 55 | 19 | 15 | 30.000% |
The world-famous chef Gordon Oliver is composing a new cookbook called "Becoming A Perfect Chef". He has a list of recipes that he wants to publish in the cookbook. Each recipe is in the form of a list of steps, where every step might depend on some previous steps (meaning a step cannot be started until all its dependencies have finished), and expected time per step.
Gordon knows that, as an expert chef, he can multitask and do as many tasks simultaneously as needed. Meanwhile, a beginner can do one task at a time, so they need to execute them sequentially. He would like to order the recipes for the cookbook by accessibility, where the lowest $\frac{\text{beginner time}}{\text{expert time}}$ ratio recipes come first.
As an example, consider the first sample case. For the oven dish, an expert chef like Gordon Oliver can prepare the tomatoes, eggplants, and sauce all at the same time (with the sauce taking the longest: $5$ time), and followed by arranging ($1$) and baking ($30$) the dish, this takes $5+1+30=36$ time. On the other hand, a beginner needs $2+2+5+1+30=40$ time to make the oven dish. This makes the accessibility ratio of the oven dish $40/36\approx 1.11$. The accessibility ratio of the ice cream is $1$ (because beginner and expert chefs both require $5+5+5+240=255$ time to prepare it), so it comes before the oven dish in the cookbook.
The input consists of:
The recipe and step names consist of at most $10$ English lowercase letters (a-z
).
The recipe names are unique and the step names are unique per recipe.
Output the names of the recipes in the cookbook, ordered by accessibility.
If there are multiple valid solutions, you may output any one of them.
2 ovendish 5 tomatoes 2 0 eggplants 2 0 sauce 5 0 arrange 1 3 tomatoes eggplants sauce bake 30 1 arrange icecream 4 mix 5 0 heat 5 1 mix churn 5 1 heat freeze 240 1 churn
icecream ovendish
2 recipea 4 stepa 5 0 stepb 5 1 stepa stepc 2 0 stepd 2 1 stepc recipeb 4 stepa 1 0 stepb 2 1 stepa stepc 2 1 stepa stepd 1 2 stepb stepc
recipea recipeb
2 recipea 2 stepa 2 0 stepb 2 1 stepa recipeb 2 stepa 5 0 stepb 5 1 stepa
recipeb recipea
ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2022 Preliminaries C번