{"trustable":false,"sections":[{"title":"","value":{"format":"MD","content":"有N个银行,第i个银行里有mi元钱,抢劫第i个银行被抓的概率为pi。给出一个危险率P,问使得被抓的概率小于等于P的情况下最多能抢多少钱。"}},{"title":"Input","value":{"format":"MD","content":"第一行一个整数T(1 \u003c\u003d T \u003c\u003d 100)表示T组数据。\n每组数据第一行包含一个小数P以及一个整数N(1 \u003c\u003d N \u003c\u003d 100),表示危险率以及银行数。\n接下来每行包含一个整数m_i(1 \u003c\u003d m_i \u003c\u003d 100)以及一个小数p_i,表示第i个银行的钱数以及增加被抓的概率。"}},{"title":"Output","value":{"format":"MD","content":"每组数据一个整数表示最多能抢到的钱数。"}},{"title":"Sample Input","value":{"format":"MD","content":"\u003cpre\u003e3\n0.04 3\n1 0.02\n2 0.03\n3 0.05\n0.06 3\n2 0.03\n2 0.03\n3 0.05\n0.10 3\n1 0.03\n2 0.02\n3 0.05\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"MD","content":"\u003cpre\u003eCase 1: 2\nCase 2: 4\nCase 3: 6\n\u003c/pre\u003e"}},{"title":"Note","value":{"format":"MD","content":"For the first case, if he wants to rob bank 1 and 2, then the probability of getting caught is **0.02 + (1 - 0.02) * .03 \u003d 0.0494** which is greater than the given probability **(0.04)**. That\u0027s why he has only option, just to rob rank 2."}}]}