{"kind":"task","effective_mode":"full","benchmark":{"kind":"benchmark","effective_mode":"full","slug":"hlce","formal_name":"Humanity's Last Code Exam","introduction":"ICPC World FinalsとIOIの競技プログラミング問題を使い、問題解決とコード生成の能力を評価します。公式紹介では235問を収録し、今回の取得は公開ICPCデータ146問を対象とします。\n\nHumanity's Last Code Exam evaluates problem solving and code generation using ICPC World Finals and IOI problems. The project describes 235 problems; this import selects its public ICPC dataset of 146 problems.","introduction_ja":"","introduction_en":"","category":"Category not supplied","task_count":null,"acquisition_status":"Acquisition status not supplied","official_url":"https://humanity-s-last-code-exam.github.io/website/","indexing_mode":"noindex"},"task_id":"57ddd935-3b04-5032-9df5-7b2709afb660","task_key":"ICPC~2dWorld~2dFinals--examples--2016~5fA","task_revision_id":"1","upstream_id":"2016_A","short_description":"Balanced Diet","config":"ICPC-World-Finals","split":"examples","body":"{\"platform\":\"atcoder\",\"question_content\":\"## Problem Statement\\n\\nEvery day, Danny buys one sweet from the candy store and eats it. The store has \\\\( m \\\\) types of sweets, numbered from 1 to \\\\( m \\\\). Danny knows that a balanced diet is important and is applying this concept to his sweet purchasing. To each sweet type \\\\( i \\\\), he has assigned a target fraction, which is a real number \\\\( f_i \\\\) (0 < \\\\( f_i \\\\) ≤ 1). He wants the fraction of sweets of type \\\\( i \\\\) among all sweets he has eaten to be roughly equal to \\\\( f_i \\\\).\\n\\nTo be more precise, let \\\\( s_i \\\\) denote the number of sweets of type \\\\( i \\\\) that Danny has eaten, and let \\\\( n = \\\\sum_{i=1}^{m} s_i \\\\). We say the set of sweets is balanced if for every \\\\( i \\\\) we have:\\n\\n\\\\[ n f_i - 1 < s_i < n f_i + 1. \\\\]\\n\\nDanny has been buying and eating sweets for a while and during this entire time the set of sweets has been balanced. He is now wondering how many more sweets he can buy while still fulfilling this condition. Given the target fractions \\\\( f_i \\\\) and the sequence of sweets he has eaten so far, determine how many more sweets he can buy and eat so that at any time the set of sweets is balanced.\\n\\n## Input\\n\\nThe input consists of three lines:\\n\\n- The first line contains two integers \\\\( m \\\\) (1 ≤ \\\\( m \\\\) ≤ 10^5), which is the number of types of sweets, and \\\\( k \\\\) (0 ≤ \\\\( k \\\\) ≤ 10^5), which is the number of sweets Danny has already eaten.\\n- The second line contains \\\\( m \\\\) positive integers \\\\( a_1, a_2, \\\\ldots, a_m \\\\). These numbers are proportional to \\\\( f_1, f_2, \\\\ldots, f_m \\\\), that is, \\\\( f_i = \\\\frac{a_i}{\\\\sum_{j=1}^{m} a_j} \\\\). It is guaranteed that the sum of all \\\\( a_j \\\\) is no larger than 10^5.\\n- The third line contains \\\\( k \\\\) integers \\\\( b_1, b_2, \\\\ldots, b_k \\\\) (1 ≤ \\\\( b_i \\\\) ≤ \\\\( m \\\\)), where each \\\\( b_i \\\\) denotes the type of sweet Danny bought and ate on the \\\\( i \\\\)-th day. It is guaranteed that every prefix of this sequence (including the whole sequence) is balanced.\\n\\n## Output\\n\\nDisplay the maximum number of additional sweets that Danny can buy and eat while keeping his diet continuously balanced. If there is no upper limit on the number of sweets, display the word `forever`.\\n\\n## Sample Input 1\\n\\n```\\n6 5\\n2 1 6 3 5 3\\n1 2 5 3 5\\n```\\n\\n## Sample Output 1\\n\\n```\\n1\\n```\\n\\n## Sample Input 2\\n\\n```\\n6 4\\n2 1 6 3 5 3\\n1 2 5 3\\n```\\n\\n## Sample Output 2\\n\\n```\\nforever\\n```\",\"question_title\":\"Balanced Diet\"}","display_format":"text","language":"","answer_status":"published","assets":[],"source_url":"https://humanity-s-last-code-exam.github.io/website/","history":"initial import","indexing_mode":"noindex","subproblems":[],"grids":[]}