{"problem":{"name":"C. Coffee","description":{"content":"Given the prices of different types of coffee (latte, cappuccino, $\\\\\\\\cdots$) for each size (small, medium, and large), and a list of orders of a group of persons. Your task is to find how much will ","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":1048576},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10199C"},"statements":[{"statement_type":"Markdown","content":"Given the prices of different types of coffee (latte, cappuccino, $\\\\\\\\cdots$) for each size (small, medium, and large), and a list of orders of a group of persons. Your task is to find how much will each person pay eventually. The cost that a person needs to pay is the cost of coffee he/she ordered in addition to the delivery fees. The delivery fees for each person are $100 \\$$ divided by the number of persons (rounded down). \n\nEventually, the final cost should ignore $1 \\$$ greater or less than what should be paid to the nearest multiple of 5 (i.e $44 \\$$ and $46 \\$$ will be rounded to $45 \\$$. However, $47 \\$$ and $48 \\$$ will not be changed).\n\nThe first line of the input contains a single integer $T$ specifying the number of test cases. \n\nEach test case begins with a line containing two integers $C$ and $P$ ($1 <= C, P <= 100$), in which $C$ is the number of different types of coffees, and $P$ is the number of unique persons.\n\nThen $C$ lines follow, giving the coffee types. Each line contains a string $N$ and three integers $S$, $M$, and $L$ ($1 <= S, M, L <= 100$), in which $N$ is a coffee name, $S$, $M$, and $L$ are the prices for small, medium, and large sizes, respectively. Each coffee type will appear exactly once per test case.\n\nThen $P$ lines follow, giving the list of orders. Each line contains three strings $X$, $Y$, and $Z$, in which $X$ is a person name, $Y$ is the coffee size ($Y in {s m a l l, thin m e d i u m, thin l a r g e}$), and $Z$ is a coffee name. It is guaranteed that all the given $P$ names are distinct, and each person will order coffee type that exists. \n\nBoth the coffee and person names are non-empty strings consisting of lowercase and uppercase English letters with a length of no more than $15$ letter.\n\nFor each test case, print $P$ lines in which each line contains two space-separated values, the name of the person and the total cost he/she will pay for his/her order. Print the persons in the same order as given in the input.\n\nThe delivery fees is $100 \\$$ and divided by $3$ persons, so each of them will pay $floor.l frac(100, 3) floor.r = 33 \\$$. \n\n## Input\n\nThe first line of the input contains a single integer $T$ specifying the number of test cases. Each test case begins with a line containing two integers $C$ and $P$ ($1 <= C, P <= 100$), in which $C$ is the number of different types of coffees, and $P$ is the number of unique persons.Then $C$ lines follow, giving the coffee types. Each line contains a string $N$ and three integers $S$, $M$, and $L$ ($1 <= S, M, L <= 100$), in which $N$ is a coffee name, $S$, $M$, and $L$ are the prices for small, medium, and large sizes, respectively. Each coffee type will appear exactly once per test case.Then $P$ lines follow, giving the list of orders. Each line contains three strings $X$, $Y$, and $Z$, in which $X$ is a person name, $Y$ is the coffee size ($Y in {s m a l l, thin m e d i u m, thin l a r g e}$), and $Z$ is a coffee name. It is guaranteed that all the given $P$ names are distinct, and each person will order coffee type that exists. Both the coffee and person names are non-empty strings consisting of lowercase and uppercase English letters with a length of no more than $15$ letter.\n\n## Output\n\nFor each test case, print $P$ lines in which each line contains two space-separated values, the name of the person and the total cost he/she will pay for his/her order. Print the persons in the same order as given in the input.\n\n[samples]\n\n## Note\n\nThe delivery fees is $100 \\$$ and divided by $3$ persons, so each of them will pay $floor.l frac(100, 3) floor.r = 33 \\$$.   The cost for \"_Mohammed_\" is $34 \\$$ for drinks, $33 \\$$ for delivery fees, this will be $67 \\$$, which is the final cost. The cost for \"_Mostafa_\" is $38 \\$$ for drinks, $33 \\$$ for delivery fees, which will be $71 \\$$, then $1 \\$$ is ignored to the nearest multiple of 5, so the final cost is $70 \\$$. The cost for \"_Ahmad_\" is $26 \\$$ for drinks, $33 \\$$ for delivery fees, which will be $59 \\$$, then $1 \\$$ is ignored to the nearest multiple of 5, so the final cost is $60 \\$$.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case:  \n- Let $ N, M \\in \\mathbb{Z} $ denote the lengths of arrays $ A $ and $ B $, respectively, with $ 1 \\leq M \\leq N \\leq 2000 $.  \n- Let $ A = (a_1, a_2, \\dots, a_N) $, $ B = (b_1, b_2, \\dots, b_M) $, and $ C = (c_1, c_2, \\dots, c_N) $ be integer arrays, where $ |a_i|, |b_j|, |c_k| \\leq 10^9 $.  \n\n**Constraints**  \n1. $ A $ and $ C $ have equal length $ N $.  \n2. $ B $ is a subsequence of $ A $ (i.e., there exists an increasing sequence of indices $ 1 \\leq i_1 < i_2 < \\dots < i_M \\leq N $ such that $ a_{i_j} = b_j $ for all $ j \\in \\{1, \\dots, M\\} $).  \n3. An element $ a_i $ may be deleted **only if** at least one of the following holds:  \n   - $ a_i = c_i $, or  \n   - There exists $ j < i $ such that $ a_j $ has already been deleted and $ c_j = c_i $.  \n\n**Objective**  \nFind the **minimum total score**, defined as the sum of $ c_i $ over all deleted elements $ a_i $, such that the remaining elements of $ A $ (in order) form $ B $.  \nIf no such deletion sequence exists, output `'No'`.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10199C","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}