Codey and School Supplies
https://www.hackerrank.com/contests/codenection-2023-final-round-closed-category/challenges/cn-c13
Question
As a new semester begins, Codey, a dilligent student, steps into a local stationery shop, ready to assemble a complete set of school supplies for its upcoming academic journey. Codey requires three essential school supplies: an eraser denoted as A
, a pencil denoted as B
, and a ruler denoted as C
. The stationery shop offers n
sets of school supplies, each with its own price, and contents, .
Codey can purchase multiple sets of school supplies, and its goal is to find the minimum total cost to obtain at least one eraser, one pencil, and one ruler. Can you assist Codey in finding the minimum total cost to acquire at least one of each of the required school supplies (eraser, pencil, and ruler) from the stationery shop?
Input Format
The first line contains an integer n
, which represents the number of sets of school supplies offered in the stationery shop.
The second lines contain an integer and a string ,where represents the price of the -th set of school supplies, and represents the contents of the school supplies set.
Constraints
String consists of 1 to 3 characters, with the only valid characters being A
, B
and C
. The arrangement of letters within string is random.
Output Format
Output the minimum cost that Codey needs to obtain at least an eraser, a pencil, and a ruler. If there is no way to obtain at least one of each of the three items, output .
Sample Inputs:
Last updated