Logo
(追記) (追記ここまで)

34396번 - Crafting Recipes 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB10109100.000%

문제

After months of hard work, you've finally finished designing a contraption for your senior capstone project. Now you just have to build it. Your design is quite complex and is composed of many parts, so you want to make sure you have enough funds to build it. You know the price of all the raw materials, and your design specifies how many parts you need to build the intermediate components. Can you determine the total price of raw materials needed to construct your contraption?

입력

The first line of input is an integer, 1ドル \leq N \leq 200,ドル specifying the number of different raw materials that make up your contraption. The following $N$ lines each contain a unique string specifying the name of a raw material, followed by an integer 1ドル \leq C \leq 1,000円$ specifying the cost of a single unit of that raw material.

The next line contains an integer 1ドル \leq M \leq 200$ specifying the number of different intermediate components that make up the design. The following $M$ lines each contain a single "recipe" specifying the parts (where each part could be either a raw material or another intermediate component), and the quantity of each of the parts, needed to build an intermediate component. The recipe for the Capstone contraption is one of these $M$ recipes.

Each recipe begins with a string specifying the name of the intermediate component, followed by an integer 1ドル \leq P \leq 2,000円$ specifying the number of different parts that make up the component. $P$ pairs of information follow: a string specifying the name of the part (which again, could be either a raw material or another intermediate component), followed by an integer 1ドル \leq Q \leq 1,000円$ specifying the quantity of that part required to build the intermediate component.

You are guaranteed that all names of raw materials and intermediate components consist of only upper- and lower-case letters.

Note that there is one and only one recipe for each intermediate component, and that no intermediate component requires itself as a part in any way.

출력

The output is a single integer specifying the total cost of raw materials needed to construct the Capstone contraption.

제한

예제 입력 1

2
WoodenGear 1
MetalSprocket 3
2
Capstone 2 StrongChassis 5 WoodenGear 2
StrongChassis 2 WoodenGear 3 MetalSprocket 5

예제 출력 1

92

예제 입력 2

3
ConductiveHinge 4
SmoothGear 4
SleekBolt 3
3
AerodynamicGearbox 2 SleekBolt 1 SmoothGear 4
Capstone 4 StrongPlate 9 SleekBolt 3 AerodynamicGearbox 2 ConductiveHinge 5
StrongPlate 3 SmoothGear 4 SmoothGear 4 AerodynamicGearbox 5

예제 출력 2

1210

노트

Sample Input 1ドル$ specifies that there are two raw materials WoodenGear and MetalSprocket that have a cost of 1ドル$ and 3ドル,ドル respectively. The input also specifies two intermediate components. The Capstone component requires five StrongChassis and two WoodenGear and the StrongChassis requires three WoodenGear and five MetalSprocket. The cost of a single StrongChasis is therefore 3ドル \times 1 + 5 \times 3 = 18,ドル and the total cost of the Capstone contraption is thus 5ドル \times 18 + 2 \times 1 = 92$.

출처

School > CS@Mines > CS@Mines HSPC 2022 > Advanced I번

  • 문제를 만든 사람: Ryan Mapes
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /