{"problem":{"name":"A. My Friend of Misery","description":{"content":"With the SCPC2015 getting closer, Noura Boubou, SCPC Head of Media, was very busy to the extent of not having time to recharge her phone's credit balance. However, her best friend, Nicole, was kind en","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":3000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10108A"},"statements":[{"statement_type":"Markdown","content":"With the SCPC2015 getting closer, Noura Boubou, SCPC Head of Media, was very busy to the extent of not having time to recharge her phone's credit balance. However, her best friend, Nicole, was kind enough to transfer her own credit for the sake of keeping Noura online 24/7.\n\nThe phone credit transfer system in Syria works in the following way: Each successful transfer operation withdraws 25 extra credit units from the sender's balance, but it doesn't cost anything when a transfer operation is unsuccessful due to non sufficient credit balance.\n\nGiven the log of credit transfer requests and the response from the system to each request, in the form: Amount of transfer, and result of operation (either successful or unsuccessful), can you find out the number of possible initial credit balance values that Nicole could have had which satisfy the given log file?\n\nNote that the initial credit balance is always a non negative integer.\n\nThe first line of input contains an integer T (1 ≤ T ≤ 256), the number of test cases.\n\nThe first line of each test case contains an integer N (1 ≤ N ≤ 105), the number of operations in the log of credit transfer requests.\n\nEach of the following N lines contains an integer mi (1 ≤ mi ≤ 106), the amount of credit to transfer, followed by . \n\nEach log contains at least one unsuccessful operation.\n\nFor each test case, print a single line that contains the number of possible initial credit balance values that Nicole could have had.\n\nWarning: large Input/Output data, be careful with certain languages.\n\n## Input\n\nThe first line of input contains an integer T (1 ≤ T ≤ 256), the number of test cases.The first line of each test case contains an integer N (1 ≤ N ≤ 105), the number of operations in the log of credit transfer requests.Each of the following N lines contains an integer mi (1 ≤ mi ≤ 106), the amount of credit to transfer, followed by .   { + } denotes a successful operation.  { - } denotes an unsuccessful operation. Each log contains at least one unsuccessful operation.\n\n## Output\n\nFor each test case, print a single line that contains the number of possible initial credit balance values that Nicole could have had.\n\n[samples]\n\n## Note\n\nWarning: large Input/Output data, be careful with certain languages.","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 $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ N_k \\in \\mathbb{Z} $ be the number of operations.  \n- Let $ M_k = (m_{k,1}, m_{k,2}, \\dots, m_{k,N_k}) $ be a sequence of transfer amounts.  \n- Let $ R_k = (r_{k,1}, r_{k,2}, \\dots, r_{k,N_k}) $ be a sequence of results, where $ r_{k,i} \\in \\{\\text{successful}, \\text{unsuccessful}\\} $.  \n\n**Constraints**  \n1. $ 1 \\le T \\le 256 $  \n2. For each $ k \\in \\{1, \\dots, T\\} $:  \n   - $ 1 \\le N_k \\le 10^5 $  \n   - $ 1 \\le m_{k,i} \\le 10^6 $ for all $ i \\in \\{1, \\dots, N_k\\} $  \n   - Each log contains at least one unsuccessful operation.  \n3. A successful transfer deducts $ m_{k,i} + 25 $ from the sender’s balance.  \n4. An unsuccessful transfer deducts nothing.  \n5. Initial credit balance $ B_0 \\in \\mathbb{Z}_{\\ge 0} $.  \n\n**Objective**  \nFor each test case $ k $, determine the number of possible initial balances $ B_0 $ such that:  \n- For each operation $ i $:  \n  - If $ r_{k,i} = \\text{successful} $, then $ B_{i-1} \\ge m_{k,i} + 25 $, and $ B_i = B_{i-1} - (m_{k,i} + 25) $.  \n  - If $ r_{k,i} = \\text{unsuccessful} $, then $ B_{i-1} < m_{k,i} + 25 $, and $ B_i = B_{i-1} $.  \n- $ B_i \\ge 0 $ for all $ i $.  \n\nLet $ S_k $ be the set of all possible $ B_0 $ satisfying the above. Compute $ |S_k| $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10108A","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}