{"problem":{"name":"C. Cheat Sheet","description":{"content":"University of Shanghai for Science and Technology starts a course called *Film Appreciation of Black Album* recently. To be the best \"Blackologist\"  in the university, Setsuna is actively preparing fo","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10262C"},"statements":[{"statement_type":"Markdown","content":"University of Shanghai for Science and Technology starts a course called *Film Appreciation of Black Album* recently. To be the best \"Blackologist\"  in the university, Setsuna is actively preparing for the exam.\n\nThe examination of the course is open book; that is to say, you can only take one single-sided cheat sheet to the exam. The cheat sheet can write $n$ characters at most.\n\nSetsuna has $m$ keywords that she wants to write on the cheat sheet. Her memory is not very good, so there may be some duplicate keywords. Each keyword consists of several visible characters(visible characters refer to characters with ASCII code between $33$ and $126$ inclusive).\n\nFor both readability and neatness, keywords written on the cheat sheet should be separated by at least one space and must be different from each other.\n\nSetsuna wants to know how many *distinct* keywords she can write down on the cheat sheet at most.\n\nUppercase and lowercase letters are considered different characters.\n\nThe first line contains two integers $n, m (1 <= n, m <= 1000)$.\n\nThe second line contains $m$ keywords separated by exactly one space. The length of each keyword is no more than $100$. It is guaranteed that keyword only consists of visible characters.\n\nOutput one integer indicating the answer.\n\nIn sample $1$, it takes $42$ characters to write all the words down. So Setsuna can write down at most four.\n\nIn sample $2$, there is only one keyword.\n\n## Input\n\nThe first line contains two integers $n, m (1 <= n, m <= 1000)$.The second line contains $m$ keywords separated by exactly one space. The length of each keyword is no more than $100$. It is guaranteed that keyword only consists of visible characters.\n\n## Output\n\nOutput one integer indicating the answer.\n\n[samples]\n\n## Note\n\nIn sample $1$, it takes $42$ characters to write all the words down. So Setsuna can write down at most four.In sample $2$, there is only one keyword.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ N, M \\in \\mathbb{Z}^+ $ denote the number of subjects and operations, respectively.  \nLet $ A = (a_1, a_2, \\dots, a_N) \\in \\mathbb{Z}^N $ be the initial marks vector.  \nFor each operation $ j \\in \\{1, \\dots, M\\} $, let $ (B_j, C_j) \\in \\mathbb{Z}^+ \\times \\mathbb{Z}^+ $ denote the maximum number of subjects that can be modified and the replacement value, respectively.\n\n**Constraints**  \n1. $ 1 \\le N, M \\le 10^5 $  \n2. $ 1 \\le a_i \\le 10^9 $ for all $ i \\in \\{1, \\dots, N\\} $  \n3. $ 1 \\le B_j \\le N $, $ 1 \\le C_j \\le 10^9 $ for all $ j \\in \\{1, \\dots, M\\} $\n\n**Objective**  \nPerform operations $ j = 1 $ to $ M $ in order. In operation $ j $, choose at most $ B_j $ subjects and set their marks to $ C_j $.  \nMaximize the final sum $ S = \\sum_{i=1}^N a_i' $, where $ a_i' $ is the final mark of subject $ i $.\n\n**Key Insight**  \nTo maximize the sum, greedily replace the smallest current marks with the largest available $ C_j $, but operations are sequential and must be applied in order.  \nThus, for each operation $ j $, replace up to $ B_j $ subjects with the smallest current marks (if $ C_j $ is greater than those marks).  \n\n**Formal Objective**  \nCompute the maximum possible sum after sequentially applying the $ M $ operations, where in operation $ j $, we may replace at most $ B_j $ of the current smallest marks with $ C_j $, in order.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10262C","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}