Jung's Restaurant
InterviewTime limit1sMemory limit256 MB
Decide whether a customer's order satisfies the restaurant rules: special items need 20000+ in regular items, service items need 50000+ combined and at most one.
- Level
Medium4 of 10
- Topics
- Hash map, Implementation, Simulation, String
- Solved
- No attempts yet
Problem
Youngki started his first semester of 2019, met many people, and blew all his money on food and drinks. To save up money to burn through in the second semester, he took a part-time job at "Jung's Restaurant", a high-end restaurant near Chung-Ang University.
Jungwoo, the owner of the restaurant, explains the restaurant's special ordering rules to Youngki, the new part-timer.
The restaurant has many menu items, but they fall into three large groups: A "regular items", B "special items", and C "service items". Regular items can be ordered freely, but special items and service items come with the following restrictions.
- A special item can be ordered only if at least 20,000 won of regular items are ordered.
- A service item can be ordered only if at least 50,000 won of regular items and special items combined are ordered.
- At most one service item can be ordered.
With all the menu items and the special ordering rules, Youngki grew confused while working. He took orders he should not have taken, got scolded by the owner, and even tripped over his own feet.
Unsure whether the orders customers place are valid, Youngki asks us for help. Let us help Youngki take orders correctly.
Input
The first line contains positive integers A, B, and C, each at most 50,000, separated by spaces.
Starting from the second line, A lines give the name and price of each regular item, separated by a space. The next B lines give the name and price of each special item, separated by a space. The next C lines give the name of each service item.
The next line contains a natural number N, at most 150,000, the number of items the customer orders.
The next N lines give the names of the items the customer orders. The same item can be ordered multiple times, and only items on the menu are ordered.
The prices of regular items and special items are positive integers at most 1,000,000. Item names consist only of lowercase English letters and are at most 20 characters long, and the names of regular items, special items, and service items are all distinct.
Output
Print "Okay" if the order Youngki received is valid, and "No" otherwise. Do not print the quotation marks.
Hint
This problem is fiction. The people, events, and settings in the problem have nothing to do with reality.