problem_id stringlengths 6 6 | user_id stringlengths 10 10 | time_limit float64 1k 8k | memory_limit float64 262k 1.05M | problem_description stringlengths 48 1.55k | codes stringlengths 35 98.9k | status stringlengths 28 1.7k | submission_ids stringlengths 28 1.41k | memories stringlengths 13 808 | cpu_times stringlengths 11 610 | code_sizes stringlengths 7 505 |
|---|---|---|---|---|---|---|---|---|---|---|
p02786 | u694422786 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\n\ncount = 0\n\nwhile h != 0:\n count += 1\n h = h//2\n\nprint(pow(2, count))', 'h = int(input())\n\ncount = 0\n\nwhile h != 0:\n count += 1\n h = h//2\n\nans = pow(2, count) - 1\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s760910900', 's506237790'] | [2940.0, 2940.0] | [17.0, 17.0] | [92, 107] |
p02786 | u697101155 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['from collections import deque\n\ndef f(x):\n if x == 1:\n return 1\n else:\n return 2 * f(H // 2) + 1 \n\nH = int(input())\n\n min = f(H)\n\nprint(min)', 'def f(x):\n if x == 1:\n return 1\n else:\n return 2 * f(x // 2) + 1 \n\nH = int(input())\n\nmin = f(H)\n\nprint(min)'] | ['Runtime Error', 'Accepted'] | ['s940872288', 's019868889'] | [2940.0, 2940.0] | [17.0, 18.0] | [164, 129] |
p02786 | u701318346 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\n\nc = 1\nwhile H >= 2**c:\n c += 2\n\nprint(2 ** c - 1)', 'H = int(input())\n\nc = 1\nwhile H >= 2**c:\n c += 1\n\nprint(2 ** c - 1)'] | ['Wrong Answer', 'Accepted'] | ['s749314253', 's554215519'] | [2940.0, 2940.0] | [17.0, 18.0] | [70, 70] |
p02786 | u711626986 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['a=int,input()\ncount=0\ns=1\nwhile True:\n if a!=1:\n a=a//2\n count+=1\n s+=2**count\n else:\n s+=2**count\n', 'a=int(input())\ncount=0\ns=1\nwhile True:\n if a>1:\n a//=int(2)\n count+=1\n s+=2**count\n else:\n s+=2**count\n print(s)\n break\n', 'a=int(input())\ncount=0\ns=1\nwhile True:\n if a!=1:\n a//=int(2)\n count+=1\n s+=2**count\n else:\n s+=2**count\n print(s)\n break', 'a=int(input())\ncount=0\ns=1\nwhile True:\n if a!=1:\n a=a//2\n count+=1\n s+=2**count\n else:\n s+=2**count\n', 'a=int(input())\ncount=0\ns=0\nwhile True:\n if a>1:\n a//=int(2)\n count+=1\n s+=2**count\n else:\n s+=1\n print(s)\n break'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Accepted'] | ['s060838824', 's096918770', 's768919751', 's888419864', 's764869478'] | [2940.0, 2940.0, 3064.0, 2940.0, 2940.0] | [18.0, 18.0, 17.0, 2104.0, 18.0] | [113, 140, 140, 114, 132] |
p02786 | u718578930 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\nres = 0\nwhile True:\n h = int(h/2)\n res += 1\n if h == 1:\n break\n else:\n pass\nprint(res+1)', 'h = int(input())\nn = 0\nwhile True:\n if h == 1:\n break\n else:\n h = int(h/2)\n n += 1\nres = 2**(n+1) - 1\nprint(res)\n'] | ['Wrong Answer', 'Accepted'] | ['s266280421', 's222810142'] | [2940.0, 2940.0] | [2103.0, 17.0] | [131, 140] |
p02786 | u723345499 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\n\ndef dev(n):\n if n = 1:\n retuen 1\n else:\n retuen 1 + dev(n//2) * 2\n\nprint(def(h))', 'h = int(input())\n\ndef dev(n):\n if n == 1:\n retuen 1\n else:\n retuen 1 + dev(n//2) * 2\n\nprint(dev(h))', 'def dev(n):\n if n = 1:\n retuen 1\n else:\n retuen 1 + dev(n//2) * 2\n\nprint(dev(h))\n', 'h = int(input())\n\ndef dev_(n):\n if n == 1:\n return 1\n else:\n return 1 + dev_(n//2) * 2\n\nprint(dev_(h))\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s036053217', 's286395148', 's528206262', 's953553239'] | [2940.0, 3064.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 17.0] | [118, 119, 101, 123] |
p02786 | u731448038 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\n#H = 10\n#K = 1\n#N = 3\n#An = [4,1,5]\n\nimport numpy as np\n\ncnt=0\nfor i in range(1000):\n if H<2**(i+1):\n break\n else:\n cnt+=1\n \n#import math\n\nif cnt ==0:\n break_cnt= 0\nelse: \n break_cnt = np.sum([i**2 for i in range(cnt)])\n \nkill_cnt = 2**cnt \n\nprint(kill_cnt + break_cnt)', 'H = int(input())\n#H = 1000000000000\n\nimport numpy as np\n\ncnt=0\nfor i in range(100):\n if H<2**(i+1):\n break\n else:\n cnt+=1\n \nif cnt == 0:\n print(1)\nelse: \n print(np.sum([2**i for i in range(cnt+1)]))'] | ['Wrong Answer', 'Accepted'] | ['s613335133', 's646243393'] | [12420.0, 12448.0] | [157.0, 152.0] | [325, 234] |
p02786 | u740267532 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\nn = 0\nwhile H//2 != 0:\n H = H//2\n n += 1\n\nprint((2**(n+1)-1))\nprint(2**(n+1))', 'H = int(input())\nn = 0\nwhile H//2 != 0:\n H = H//2\n n += 1\n\nprint((2**(n+1)-1))'] | ['Wrong Answer', 'Accepted'] | ['s600590087', 's762421977'] | [2940.0, 3188.0] | [17.0, 18.0] | [100, 84] |
p02786 | u740284863 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\nans = 0\nwhile True:\n if h == 1:\n break\n elif h == 2:\n ans += 1\n break\n else:\n h //= 2\n ans += 1\nprint(2**ans)', 'h = int(input())\nans = 0\nwhile True:\n if h == 1:\n break\n elif h == 2:\n ans += 1\n break\n else:\n h //= 2\n ans += 1\nprint(2**(ans+1)-1)'] | ['Wrong Answer', 'Accepted'] | ['s702752418', 's355570325'] | [2940.0, 2940.0] | [17.0, 17.0] | [170, 176] |
p02786 | u746849814 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import math\n\nh = int(input())\n \nsplit_num = math.floor(math.log2(h)) + 1\nattack_num = sum([2**s for s in range(1, split_num+1)])\n \nprint(attack_num)', 'h = int(input())\n\nsplit_num = math.floor(math.log2(h)) + 1\nattack_num = sum([2**s for s in range(1, split_num+1)])\n\nprint(attack_num)', 'H = int(input())\n\nh = H\nattack = []\ndivision = 0\nwhile h >= 1:\n h /= 2\n attack.append(2**division)\n division += 1\nprint(sum(attack))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s196489525', 's859670780', 's563912054'] | [2940.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0] | [148, 133, 141] |
p02786 | u749512407 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\nimport pdb; pdb.set_trace()\ndef atk(n):\n if n==1: return 1\n return 1 + 2*(atk(n//2))\n\nprint(atk(H))', 'H = int(input())\ndef atk(n):\n if n==1: return 1\n return 1 + 2*(atk(n//2))\n\nprint(atk(H))'] | ['Runtime Error', 'Accepted'] | ['s033326649', 's117318216'] | [11660.0, 9096.0] | [48.0, 31.0] | [118, 90] |
p02786 | u749770850 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\nprint(h.bit_length())\nprint(2 ** (h.bit_length()) -1)', 'h = int(input())\nprint(2 ** (h.bit_length()) -1)'] | ['Wrong Answer', 'Accepted'] | ['s225143457', 's080685858'] | [2940.0, 2940.0] | [17.0, 19.0] | [70, 48] |
p02786 | u753092134 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['def hel(h):\n if h==0:\n return 1\n else:\n return (2*hel(int(h/2))+1)\nhealth=int(input())\nprint(hel(health))\n', 'def hel(h):\n if h==0:\n return 1\n else:\n return (hel(int(h/2))+hel(int(h/2)))\nhealth=int(input())\nprint(hel(health))', 'def hel(h):\n if h==0:\n return 1\n else:\n return (hel(int(h/2))+hel(int(h/2))\nhealth=int(input())\nprint(hel(health))', 'def hel(h):\n if h==1:\n return 1\n else:\n return (2*hel(int(h/2))+1)\nhealth=int(input())\nprint(hel(health))\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s297049138', 's946134094', 's946850684', 's986677150'] | [2940.0, 2940.0, 2940.0, 2940.0] | [18.0, 2104.0, 17.0, 17.0] | [114, 123, 122, 114] |
p02786 | u755545520 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h=int(input())\na=0\nwhile True:\n h=h//2\n a+=1\n if =h//2==0:\n break\n\nprint(2**a-1)\n', 'h=int(input())\na=1\n\nif h ==1:\n print(1)\nelse:\n while True:\n h=h//2\n a+=1\n if h//2==0:\n break\n\n print(2**a-1)'] | ['Runtime Error', 'Accepted'] | ['s697318630', 's598645144'] | [2940.0, 2940.0] | [17.0, 18.0] | [82, 113] |
p02786 | u762275701 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\n\ndouble = 0\nfor i in range(h, 1, -1):\n if h == 1:\n break\n h = h // 2\n double += 1\n\nprint(double + 1)\ntotal = 0\nfor i in range(double + 1):\n total += pow(2, i)\nprint(total)', 'h = int(input())\n\ndouble = 0\nfor i in range(h, 1, -1):\n if h == 1:\n break\n h = h // 2\n double += 1\n\ntotal = 0\nfor i in range(double + 1):\n total += pow(2, i)\nprint(total)'] | ['Wrong Answer', 'Accepted'] | ['s614866762', 's275987873'] | [3060.0, 3060.0] | [17.0, 17.0] | [195, 177] |
p02786 | u763380276 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import bisect\n\nn=int(input())\nlst=[1]\nlst2=[1]\nfor i in range(1,41):\n lst.append(2**i)\n lst2.append(lst2[i-1]+lst[i])\n \nind=bisect_left(lst,n)\nprint(lst2[ind])', 'from bisect import bisect_right\n \nn=int(input())\nlst=[1]\nlst2=[1]\nfor i in range(1,41):\n lst.append(2**i)\n lst2.append(lst2[i-1]+lst[i])\n \nind=bisect_right(lst,n)\nprint(lst2[ind])', 'from bisect import bisect_right\n \nn=int(input())\nlst=[1]\nlst2=[1]\nfor i in range(1,41):\n lst.append(2**i)\n lst2.append(lst2[i-1]+lst[i])\n \nind=bisect_right(lst,n)\nprint(lst2[ind-1])'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s026428575', 's662526987', 's474000843'] | [3060.0, 3060.0, 3060.0] | [18.0, 19.0, 17.0] | [162, 182, 184] |
p02786 | u767664985 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['def attack_count(N):\n if N == 1:\n return 1\n else:\n return 2 * attack_count(N//2)\n\nH = int(input())\nprint(attack_count(H))\n', 'def attack_count(N):\n if N == 1:\n return 1\n else:\n return 2 * attack_count(N//2) + 1\n\nH = int(input())\nprint(attack_count(H))\n'] | ['Wrong Answer', 'Accepted'] | ['s289381941', 's893274920'] | [2940.0, 2940.0] | [17.0, 19.0] | [142, 146] |
p02786 | u779728630 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\n\nans = 1\n\nwhile H > 1:\n ans *= 2\n H /= 2\nprint(ans - 1)', 'H = int(input())\n\nans = 0\nbase = 1\n\nwhile H >= 1:\n# print(H)\n ans += base\n base *= 2\n H /= 2\n \nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s899577367', 's710376733'] | [2940.0, 2940.0] | [17.0, 17.0] | [74, 110] |
p02786 | u780475861 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import sys\nfrom functools import lru_cache\nsys.setrecursionlimit(1000000)\n\n\n@lru_cache(maxsize=None)\ndef a(n):\n if n == 1:\n return 1\n return 1 + 2 * a(n // 2)\n\n\nprint(a(1000000000000))\n', 'import sys\nsys.setrecursionlimit(1000000)\n\n\ndef a(n):\n if n == 1:\n return 1\n return 1 + 2 * a(n // 2)\n\n\nprint(a(int(input())))\n'] | ['Wrong Answer', 'Accepted'] | ['s788879296', 's554598115'] | [3700.0, 2940.0] | [22.0, 17.0] | [198, 140] |
p02786 | u782616557 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H=int(input())\nnum=0\nX=H\nwhile True:\n X=H//2\n num+=1\n if X==0:\n break\nprint(2**num -1)\n', 'H=int(input())\nnum=0\nX=H\nwhile True:\n X=X//2\n num+=1\n if X==0:\n break\nprint(2**num -1)\n'] | ['Time Limit Exceeded', 'Accepted'] | ['s457768026', 's077931465'] | [2940.0, 2940.0] | [2104.0, 17.0] | [93, 93] |
p02786 | u796708718 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\ni = 0\nwhile H > 1:\n H = H/2\n i += 1\nprint(2**i-1)\n', 'H = int(input())\ni = 1\ncnt = 0\nwhile H > 1:\n H = -(-H//2)\n print("H=%d,i=%d" % (H,i))\n cnt += 1\n i += 2**(cnt-1) \nprint(i)', 'H = int(input())\ni = 0\nwhile H > 1:\n H = -(-H//2)\n i += 1\nprint(2**i-1)', 'H = int(input())\ni = 1\ncnt = 0\nwhile H > 1:\n H = -(-H//2)\n cnt += 1\n i += 2**(cnt-1) \nprint(i)', 'H = int(input())\ni = 0\nif H ==1:\n print(1)\nelse:\n while H > 1:\n H = -(- H//2)\n i += 1\n print(2**(i)-1)', 'H = int(input())\ni = 1\nwhile H > 1:\n H = -(-H//2)\n if H > 1:\n i += 1\nprint(2**i-1)', 'H = int(input())\ni = 1\nwhile H > 1:\n H = -(-H//2)\n print("H=%d,i=%d" % (H,i))\n if H >= 1:\n i += 1\nprint(2**i-1)', 'H = int(input())\ncnt = 0\ni = 0\nwhile H > 0:\n H //= 2\n i += 2**cnt\n cnt += 1\nprint(i)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s066261874', 's260719669', 's331817716', 's334638664', 's431003354', 's445852847', 's958935458', 's663936198'] | [2940.0, 3064.0, 2940.0, 2940.0, 3068.0, 3064.0, 2940.0, 2940.0] | [17.0, 24.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0] | [69, 134, 73, 103, 125, 95, 127, 93] |
p02786 | u805841327 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['HP=int(input())\n\nprint(Caracal(HP))\n\ndef Caracal(x):\n if x>1:\n ans=1+Caracal(x//2)*2\n elif x==1:\n ans=1\n print(x,ans)\n return ans\n', 'HP=int(input())\n\ndef Caracal(x):\n if x>1:\n ans=1+Caracal(x//2)*2\n elif x==1:\n ans=1\n else:\n ans=-1\n print(x,ans)\n return ans\n\nprint(Caracal(HP))', 'HP=int(input())\n\nprint(Caracal(HP))\n\ndef Caracal(x):\n if x>1:\n ans=1+Caracal(x//2)*2\n elif x==1:\n ans=1\n return ans\n', 'HP=int(input())\n\ndef Caracal(x):\n if x>1:\n ans=1+Caracal(x//2)*2\n elif x==1:\n ans=1\n return ans\n\nprint(Caracal(HP))'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s125730775', 's312131282', 's540269953', 's880256726'] | [2940.0, 3060.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0, 17.0] | [140, 158, 125, 124] |
p02786 | u812576525 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ["H = int(input())\n\ncnt = H\nB = [H]\nif H == 1:\n print('0')\nelse:\n for i in range(100000000000):\n cnt = cnt//2\n B.append(cnt)\n if cnt == 1:\n break\n C =[1]\n for i in range(1,1001):\n C.append(C[i-1]*2)\n ans= 0\n for i in range(len(B)):\n ans +=C[i]\n print(ans)", "H = int(input())\n\ncnt = H\nB = [H]\nif H == 1:\n print('0')\nelse:\n for i in range(100000000000):\n cnt = cnt//2\n B.append(cnt)\n if cnt == 1:\n break\n C =[1]\n for i in range(1,1001):\n C.append(C[i-1]*2)\n ans= 0\n for i in range(len(B)):\n ans +=C[i]\n print(ans)", "H = int(input())\ncnt = H\nB = [H]\n\nif H == 1:\n ans == 10000000001\nelse:\n for i in range(100000000000):\n cnt = cnt//2\n B.append(cnt)\n if cnt == 1:\n break\n\nC =[1]\nfor i in range(1,1001):\n C.append(C[i-1]*2)\n\nif ans == 10000000001:\n print('0')\nelse:\n ans= 0\n for i in range(len(B)):\n ans +=C[i]\nprint(ans)", "H = int(input())\ncnt = H\nans = 0\nB = [H]\n\nif H == 1:\n ans == 'NA'\nelse:\n for i in range(100000000000):\n cnt = cnt//2\n B.append(cnt)\n if cnt == 1:\n break\n\nC =[1]\nfor i in range(1,1001):\n C.append(C[i-1]*2)\n\nif ans == 'NA':\n print('0')\nelse:\n for i in range(len(B)):\n ans +=C[i]\nprint(ans)"] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s104812544', 's582503312', 's596681807', 's169557929'] | [3064.0, 2940.0, 3064.0, 3064.0] | [28.0, 17.0, 18.0, 17.0] | [348, 304, 358, 341] |
p02786 | u819593641 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import fractions\nprint(int(fractions.math.log2(int(input()))))\n', 'import fractions\npower = int(fractions.math.log2(int(input())))\nans = 0\nfor p in range(power+1):\n ans += 2**p\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s531169127', 's114927197'] | [5048.0, 5688.0] | [35.0, 50.0] | [63, 122] |
p02786 | u825769322 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\n\nn = 0\nwhile 2**n < h:\n n += 1\n\nprint(2**n-1)', 'h = int(input())\n\nn = 0\nwhile 2**n <= h:\n n += 1\n\nprint(2**n-1)'] | ['Wrong Answer', 'Accepted'] | ['s904819739', 's218524312'] | [3064.0, 2940.0] | [19.0, 17.0] | [65, 66] |
p02786 | u829008868 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H=int(input())\nans = 0\nprint(H)\nwhile H > 1:\n if H%2 == 0:\n H = H/2\n ans += 1\n else:\n H = (H-1)/2\n ans += 1\nN = 2**ans\ndef fight(k):\n if k == 1:\n return 1\n else:\n return 2*fight(k/2)+1\n \n \nprint(fight(N))\n', 'H=int(input())\nans = 0\n\nwhile H > 1:\n if H%2 == 0:\n H = H/2\n ans += 1\n else:\n H = (H-1)/2\n ans += 1\nN = 2**ans\ndef fight(k):\n if k == 1:\n return 1\n else:\n return 2*fight(k/2)+1\n \n \nprint(fight(N))'] | ['Wrong Answer', 'Accepted'] | ['s147173603', 's573371681'] | [3060.0, 3060.0] | [17.0, 18.0] | [269, 260] |
p02786 | u833337336 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import math\nres = 0\nnum_enemy = 1\nn = int(input())\nwhile True:\n res += num_enemy\n if n==1:\n break\n num_enemy *= 2\n n = n//2\nres', 'res = 0\nnum_enemy = 1\nn = int(input())\nwhile True:\n res += num_enemy\n if n==1:\n break\n num_enemy *= 2\n n = n//2\nprint(res)'] | ['Wrong Answer', 'Accepted'] | ['s652628843', 's859151763'] | [2940.0, 2940.0] | [17.0, 18.0] | [146, 141] |
p02786 | u845573105 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\ncount = 0\nans = 0\nwhile H>1:\n H = H//2\n ans += 2**i\n count += 1\nans += 2**i\nprint(ans)', 'H = int(input())\ncount = 0\nans = 0\nwhile H>1:\n H = H//2\n ans += 2**i\n count += 1\nans += 2**i\nprint(ans)', 'H = int(input())\ncount = 0\nans = 0\nwhile H>1:\n H = H//2\n ans += 2**count\n count += 1\nans += 2**count\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s740595342', 's929200778', 's042107696'] | [9152.0, 9084.0, 9064.0] | [31.0, 23.0, 32.0] | [106, 106, 114] |
p02786 | u855781168 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import math\n\nh = int(input())\n\ndef sum(list,k):\n s = 0\n for i in range(len(list)-k):\n s = s+ list[i]\n return s\n\nx = math.ceil(math.log2(h*1.0))\n\n\nprint(2**x - 1)\n\n', 'import math\n\nh = int(input())\n\ndef sum(list,k):\n s = 0\n for i in range(len(list)-k):\n s = s+ list[i]\n return s\n\nx = math.ceil(math.log2((h+1)*1.0))\n\n\nprint(2**x - 1)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s953922455', 's578439961'] | [3060.0, 2940.0] | [18.0, 19.0] | [208, 212] |
p02786 | u857070771 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h=int(input())\ncount=0\nwhile h>1:\n\th = h // 2\n\tconut += 1\nprint(2 ** (count+1) - 1)', 'h=int(input())\ncount=0\nwhile h>1:\n\th = h // 2\n\tcount += 1\nprint(2 ** (count+1) - 1)\n'] | ['Runtime Error', 'Accepted'] | ['s694760062', 's105347846'] | [2940.0, 2940.0] | [17.0, 17.0] | [84, 85] |
p02786 | u857330600 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['def car(n):\n if n==1:\n return 1\n elif n%2==0:\n return car(n//2)*2\n else:\n return car((n-1)//2)*2\n \nN=int(input())\nprint(car(N))', 'def car(n):\n if n==1:\n return 1\n elif n%2==0:\n return (car(n//2)*2)+1\n else:\n return (car((n-1)//2)*2)+1\n \nN=int(input())\nprint(car(N))'] | ['Wrong Answer', 'Accepted'] | ['s988575804', 's005781395'] | [2940.0, 3064.0] | [17.0, 18.0] | [140, 148] |
p02786 | u860966226 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['n = int(input())\nans = 0\ni = 0\n\nwhile n > 0:\n ans += n * 2 ** i\n i += 1\n n = n // 2\n\nprint(ans)\n', 'import math\n\nn = int(input())\nkaisu = math.log2(n)\nans = 0\n\nfor i in range(kaisu):\n ans += 2 ** i\n\nprint(ans)\n', 'import math\n \nn = int(input())\nkaisu = math.log2(n)\nans = 0\n \nfor i in range(int(kaisu)):\n ans += 2 ** i\n \nprint(ans)\n', 'import math\n \nn = int(input())\nkaisu = math.log2(n) + 1\nans = 0\n \nfor i in range(int(kaisu)):\n ans += 2 ** i\n \nprint(ans)\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s070115296', 's136231643', 's927138519', 's466217429'] | [2940.0, 2940.0, 3060.0, 3188.0] | [18.0, 17.0, 19.0, 18.0] | [99, 111, 119, 123] |
p02786 | u877415670 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h,n=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(n)]\n \ndp=[0]*h\nfor i in range(h):\n _min = 10**10\n for g in range(n):\n if i>=ab[g][0]:\n _min = min(ab[g][1]+dp[i-ab[g][0]], _min)\n else:\n _min = min(ab[g][1], _min)\n dp[i]=_min\nprint(dp[-1])', 'h=int(input())\n\nans=0\ni=0\nwhile True:\n ans+=(2**i)\n h//=2\n i+=1\n if h==0:\n break\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s487733102', 's201299547'] | [3064.0, 2940.0] | [17.0, 18.0] | [313, 110] |
p02786 | u882209234 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | [' H = int(input())\n\n ans = 0\n t = 1\n while H > 0:\n ans += t\n H //= 2\n t *= 2\n print(ans)', 'H = int(input())\n\nans = 0\nt = 1\nwhile H > 0:\n ans += t\n H //= 2\n t *= 2\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s190057024', 's130500153'] | [2940.0, 2940.0] | [17.0, 17.0] | [123, 91] |
p02786 | u890183245 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\nans = []\nfor i in range (1,43):\n if 2**(i-1)<H and H <2**(i):\n for j in range (0,i):\n ans.append(2**j)\n else:\n pass\nprint(sum(ans))', 'H = int(input())\nif H==1:\n print(1)\nelif 2 <= H and H <= 3:\n print(3)\nelif 4 <= H and H <= 7:\n print(7)\nelse:\n for i in range (1,43):\n if 2**(i-1)<=H and H <2**(i):\n print(2**(i)-1)\n else:\n pass'] | ['Wrong Answer', 'Accepted'] | ['s454365216', 's728579493'] | [3060.0, 3060.0] | [17.0, 17.0] | [165, 214] |
p02786 | u891438775 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import math\nH=int(input())\nsum([2**x for x in range(math.floor(math.log2(H))+1)])', 'import math\nH=int(input())\nprint(sum([2**x for x in range(math.floor(math.log2(H))+1)]))'] | ['Wrong Answer', 'Accepted'] | ['s535575113', 's789675024'] | [2940.0, 3064.0] | [17.0, 19.0] | [81, 88] |
p02786 | u891876269 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\ncnt = 0\nif H >= 2:\n while H >= 2:\n H = int(H/2)\n cnt += 1\n a = 2 ** cnt\n ans = sum([2**i for i in range(0, cnt, 1)]) + cnt\n print(ans)\n \n \nelse:\n print(H)\n ', 'H = int(input())\ncnt = 0\nif H >= 2:\n while H >= 2:\n H = int(H/2)\n cnt += 1\n ans = sum([2**i for i in range(0, cnt+1, 1)])\n print(ans)\n\nelse:\n print(H)\n '] | ['Wrong Answer', 'Accepted'] | ['s995049596', 's528803841'] | [2940.0, 2940.0] | [18.0, 17.0] | [209, 163] |
p02786 | u891884439 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\ni = 0\nresult = 0\n\nwhile True:\n\n H //= 2\n i += 1\n result += 2**i\n if H == 1:\n break\n\nprint(result)', 'H = int(input())\ni = 0\nresult = 0\n \nwhile True:\n result += 2**i\n H //= 2\n i += 1\n if H == 0:\n break\n \nprint(result)'] | ['Wrong Answer', 'Accepted'] | ['s944690754', 's610690894'] | [2940.0, 2940.0] | [2103.0, 17.0] | [133, 134] |
p02786 | u894934980 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import math\ndef f(x):\n if x == 1:\n return 1\n else:\n return f(math.ceil(x/2)) + f(math.ceil(x/2))\nH = int(input())\nprint(f(H))', 'import math\ndef f(x):\n if x == 1:\n return 1\n else:\n return 2*f(math.floor(x/2)) + 1\nH = int(input())\nprint(f(H))'] | ['Wrong Answer', 'Accepted'] | ['s097594905', 's882588733'] | [3060.0, 3060.0] | [2104.0, 17.0] | [145, 132] |
p02786 | u900548304 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['def time(h):\n if h == 1:\n return 1\n else:\n return time(h//2)*2 + 1\n\nprint(time(H))', 'H = int(input())\n\ndef time(h):\n if h == 1:\n return 1\n elif h > 1:\n return time(h//2)*2 + 1\n\nprint(time(H))'] | ['Runtime Error', 'Accepted'] | ['s450973999', 's901860166'] | [2940.0, 2940.0] | [17.0, 17.0] | [102, 126] |
p02786 | u904081717 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['N = input()\ncnt = 0\n\nwhile N>1:\n N = int(N/2)\n cnt +=1\n\nprint(2**(cnt+1)-1)', 'N = int(input())\ncnt = 0\n\nwhile N>1:\n N = int(N/2)\n cnt +=1\n\nprint(2**(cnt+1)-1)'] | ['Runtime Error', 'Accepted'] | ['s783333076', 's870560790'] | [2940.0, 3064.0] | [17.0, 17.0] | [81, 86] |
p02786 | u904331908 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\n\ni = 0\nwhile True:\n if H < 2 ** i:\n n = i-1\n break\n i += 1\n\nprint(2**n -1)\n\n\n ', 'H = int(input())\n\ni = 0\nwhile True:\n if H < 2 ** i:\n n = i\n break\n i += 1\n\nprint(2**n -1)\n'] | ['Wrong Answer', 'Accepted'] | ['s256111162', 's925297604'] | [9064.0, 9096.0] | [32.0, 28.0] | [104, 98] |
p02786 | u904639778 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ["def rec_count(num):\n if num == 0:\n return 0\n elif num == 1:\n return 1\n elif num == 2:\n return 3\n elif num == 3:\n return 3\n else:\n split = num // 2\n return 1 + 2 * rec_count(split)\n\nh = int('1026')\nprint(rec_count(h))", 'def rec_count(num):\n if num == 1:\n return 1\n elif num == 2:\n return 3\n elif num == 3:\n return 3\n else:\n split = num // 2\n return 1 + 2 * rec_count(split)\n\nh = int(input())\nprint(rec_count(h))\n'] | ['Wrong Answer', 'Accepted'] | ['s026061523', 's474155326'] | [2940.0, 3064.0] | [17.0, 17.0] | [273, 239] |
p02786 | u905203728 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['from math import ceil\nh=int(input())\ncnt=0\nwhile h!=1:\n cnt +=1\n h=ceil(h/2)\nprint(2**cnt-1)', 'h=int(input())\ncnt=0\nwhile h!=0:\n cnt +=1\n h //=2\nprint(2**cnt-1)'] | ['Wrong Answer', 'Accepted'] | ['s535405414', 's870873264'] | [2940.0, 2940.0] | [18.0, 17.0] | [98, 71] |
p02786 | u909375661 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\ncnt = 0\nn = math.floor(math.log2(H))\nans = 0\nfor i in range(n+1):\n cnt += int(math.pow(2,i))\nprint(cnt)', 'import math\nH = int(input())\ncnt = 0\nn = math.floor(math.log2(H))\nans = 0\nfor i in range(n+1):\n cnt += int(math.pow(2,i))\nprint(cnt)'] | ['Runtime Error', 'Accepted'] | ['s728653193', 's105197621'] | [3060.0, 3060.0] | [17.0, 17.0] | [123, 135] |
p02786 | u909616675 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H=int(input())\na=1\nans=1\nwhile True:\n if a>H:\n break\n ans=ans+a\n a=a*2\n\nprint(ans)', 'H=int(input())\na=1\nans=0\nwhile True:\n if a>H:\n break\n ans=ans+a\n a=a*2\n \nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s825149892', 's991865703'] | [2940.0, 2940.0] | [17.0, 17.0] | [89, 89] |
p02786 | u910632349 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h=int(input())\na=[]\nwhile h>=1:\n a.append(h)\n h//2\ncount=0\nfor i in a:\n while a[i]>=1:\n count+=1\n a[i]//2\nprint(count)', 'n=int(input())\na=0\nb=0\nwhile n!=0:\n n=n//2\n a+=2**b\n b+=1\nprint(a)'] | ['Time Limit Exceeded', 'Accepted'] | ['s727003922', 's078571606'] | [191844.0, 9064.0] | [2210.0, 31.0] | [141, 75] |
p02786 | u912359563 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\nA = []\nA.append((A, 1))\nans = 0\nwhile len(A) > 0:\n h, c = A[0]\n A.pop(0)\n ans += c\n A.append((h//2, c*2))\nprint(ans)', 'H = int(input())\nA = []\nA.append((H, 1))\nans = 0\nwhile len(A) > 0:\n h, c = A[0]\n A.pop(0)\n ans += c\n if h != 1:\n A.append((h//2, c*2))\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s515862465', 's112561691'] | [3060.0, 3060.0] | [17.0, 17.0] | [137, 164] |
p02786 | u914802579 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\nl=1;k=2\nwhile k<h:\n l=2*l+1\n k*=2\nprint(l)\n', 'h = int(input())\nl=0\nwhile h>0:\n l=2*l+1\n h//=2\nprint(l)'] | ['Wrong Answer', 'Accepted'] | ['s264208312', 's927884819'] | [2940.0, 2940.0] | [17.0, 18.0] | [62, 58] |
p02786 | u916637712 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['n=int(input())\n\nfor i in range(50):\n if n<2**i:\n break\nprint(i)\n\nout=0\nfor k in range(i):\n out+=2**k\n\nprint(out)\n', 'n=int(input())\n\nfor i in range(50):\n if n<2**i:\n break\n#print(i)\n\nout=0\nfor k in range(i):\n out+=2**k\n\nprint(out)\n'] | ['Wrong Answer', 'Accepted'] | ['s120602374', 's158082617'] | [2940.0, 2940.0] | [17.0, 18.0] | [126, 127] |
p02786 | u917444023 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ["import math\nk=int(input())\nans=0\nif k==1:\n print('1')\ni=0\nwhile True:\n k=math.floor(k/2)\n ans+=2**i\n i+=1\n if k=<1:\n print(ans)\n exit()", "import math\nk=int(input())\nans=0\nif k==1:\n print('1')\ni=0\nwhile True:\n k=math.floor(k/2)\n ans+=2**i\n i+=1\n if k=<1:\n print(ans)\n exit()", 'import math\nk=int(input())\nans=0\nif k==1:\n print(ans)\ni=0\nwhile True:\n k=math.floor(k/2)\n ans+=2**i\n i+=1\n if k<=1:\n print(ans)\n exit()', 'import math\nk=int(input())\ni=0\nwhile k>=1:\n k=math.floor(k/2)\n i+=1\nprint(2**i-1)'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s007322501', 's692582235', 's817251728', 's047290932'] | [2940.0, 2940.0, 3060.0, 3060.0] | [17.0, 18.0, 18.0, 17.0] | [146, 146, 146, 83] |
p02786 | u918601425 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['N=int(input())\na=0\nd=1\nwhile d<=N:\n a+=d\n d*=2\nprint(ans)', 'N=int(input())\na=0\nd=1\nwhile d<=N:\n a+=d\n d*=2\nprint(a)\n'] | ['Runtime Error', 'Accepted'] | ['s164685724', 's124497808'] | [2940.0, 2940.0] | [17.0, 17.0] | [59, 58] |
p02786 | u919681556 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ["h, n = map(int, input().split())\n\nm = [i for i in input().split()]\n\nresult = 0\n\nfor i in m:\n result += int(i)\n\nif result >= h:\n print('Yes')\nelse:\n print('No')", "h, n = map(int, input().split())\n\nm = [i for i in input().split()]\n\nresult = 0\n\nfor i in m:\n result += int(i)\n\nif result >= h:\n print('Yes')\nelse:\n print('No')", 'h = int(input())\n\nresult = 0\ni = 1\nwhile h > 0:\n h = h // 2\n result = result + i\n i *= 2\n\nprint(result)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s046420543', 's063673956', 's713945734'] | [2940.0, 2940.0, 2940.0] | [17.0, 18.0, 17.0] | [168, 168, 112] |
p02786 | u933129390 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\ndep = 0\ndef log_num(n):\n global dep\n if n == 1:\n return dep\n else:\n dep += 1\n log_num(n//2)\nlog_num(h)\nans = 1\nfor i in range(dep+1):\n ans *= 2\nprint(ans)\n', 'h = int(input())\ndep = 0\ndef log_num(n):\n global dep\n if n == 1:\n return dep\n else:\n dep += 1\n log_num(n//2)\nlog_num(h)\nans = 1\nfor i in range(dep+1):\n ans *= 2\nprint(ans-1)\n'] | ['Wrong Answer', 'Accepted'] | ['s325145286', 's079515059'] | [2940.0, 3064.0] | [17.0, 17.0] | [205, 207] |
p02786 | u934052933 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['\ndef main():\n import math\n\n H = int(input())\n if H == 1:\n print(1)\n else:\n count = int(math.log(H, 2))\n ans = 0\n for i in range(count+1):\n ans += 2 ** (i)\n print(ans)\n\nif __name__ == "__main__":\n main()', '\ndef main():\n import math\n\n H = int(input())\n if H == 1:\n print(1)\n else:\n count = int(math.log(H, 2))\n ans = 0\n for i in range(count+1):\n ans += 2 ** (i)\n print(ans)\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s337378885', 's255278244'] | [2940.0, 3060.0] | [17.0, 19.0] | [267, 263] |
p02786 | u938486382 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['print(int(input()).bit_length())\n', 'print(2**int(input()).bit_length()-1)\n'] | ['Wrong Answer', 'Accepted'] | ['s037519582', 's311372747'] | [9140.0, 9144.0] | [28.0, 28.0] | [33, 38] |
p02786 | u944643608 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\ntotal = 1\nwhile H != 1:\n H = H // 2\n total += 1\nfor i in range(tatal):\n number += 2 ** i\nprint(number)', 'H = int(input())\ntotal = 1\nwhile H > 1:\n H = H // 2\n if H != 0:\n total += 1\nnumber = 0\nfor i in range(tatal):\n number += 2 ** i\nprint(number)\n', 'H = int(input())\ndef re(a):\n if a == 1:\n return 1\n return 2 * re(a//2) + 1\nprint(re(H))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s401844651', 's955607418', 's036469419'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 18.0] | [122, 148, 92] |
p02786 | u946322619 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['def calc(x):\n return 1 + calc(x // 2)\n\nh = int(input())\n\nprint(calc(h))', 'def calc(x):\n if x == 0:\n return 0;\n return 1 + calc(x // 2) * 2\n\nh = int(input())\n\nprint(calc(h))\n'] | ['Runtime Error', 'Accepted'] | ['s756816503', 's323555682'] | [3864.0, 2940.0] | [73.0, 17.0] | [72, 104] |
p02786 | u946424121 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import math\nh = int(input())\nfor i in range(h):\n if h == 0:\n print(2**(i) - 1)\n break\n h = math.floor(h/2)', 'h = int(input())\nfor i in range(1000):\n if h == 0:\n a = 2 ** (i)- 1\n print(a)\n break\n h = h // 2'] | ['Wrong Answer', 'Accepted'] | ['s628063393', 's620909313'] | [3060.0, 2940.0] | [17.0, 17.0] | [126, 124] |
p02786 | u949802245 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import math\n\nintegrationEnemy = int(input())\nsqrtCount = 0\nharf = 10\n\nwhile True:\n if harf == 1:\n sqrtCount += 1\n break\n elif harf == 0:\n break\n else:\n sqrtCount += 1\n\n if sqrtCount == 1:\n harf = math.floor(integrationEnemy / 2)\n print(sqrtCount , harf)\n else:\n harf = math.floor(harf / 2)\n print(sqrtCount , harf)\n\nprint(sqrtCount)\nprint(2**(sqrtCount)- 1)', 'import math\n\nintegrationEnemy = int(input())\nsqrtCount = 0\nharf = 10\n\nwhile True:\n if harf == 1:\n sqrtCount += 1\n break\n elif harf == 0:\n break\n else:\n sqrtCount += 1\n\n if sqrtCount == 1:\n harf = math.floor(integrationEnemy / 2)\n else:\n harf = math.floor(harf / 2)\n\nprint(2**(sqrtCount)- 1)'] | ['Wrong Answer', 'Accepted'] | ['s928379199', 's271616411'] | [3064.0, 3060.0] | [17.0, 17.0] | [428, 347] |
p02786 | u951947571 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\n\nimport math\n\nif h == 1:\n print(1)\n\nelse:\n n_attacks = 0\n while h / 2 >= 1:\n n_attacks += 1\n h = math.floor(h/2)\n\n gsum = 1\n\n for x in range(n_attacks + 1):\n gsum += 2 ** (x + 1)\n \n print(gsum)', 'h = int(input())\n\nimport math\n\nif h == 1:\n print(1)\n\nelse:\n n_attacks = 0\n while h / 2 >= 1:\n n_attacks += 1\n h = math.floor(h/2)\n\n gsum = 1\n\n for x in range(n_attacks):\n gsum += 2 ** (x + 1)\n \n print(gsum)'] | ['Wrong Answer', 'Accepted'] | ['s152439595', 's713220594'] | [3060.0, 3060.0] | [18.0, 18.0] | [256, 252] |
p02786 | u966546644 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\n\nif H == 1:\n print(1)\n\nelse:\n sp = 0\n count = 1\n while H != 1:\n H = H // 2\n count *= 2\n sp += count\n print(count*2)', 'H = int(input())\n\nif H == 1:\n print(1)\n\nelse:\n sp = 0\n count = 1\n while H != 1:\n H = H // 2\n count *= 2\n sp += count\n print(count*2-1)'] | ['Wrong Answer', 'Accepted'] | ['s139769581', 's636026009'] | [2940.0, 2940.0] | [17.0, 17.0] | [146, 148] |
p02786 | u969848070 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import math\nH = int(input())\nx = math.log2(H)\nprint(2 ** (x+1) - 1)', 'import math\nH = int(input())\nx = math.log2(H)\nprint(2 ** int(x+1) - 1)'] | ['Wrong Answer', 'Accepted'] | ['s907499445', 's622345389'] | [3064.0, 2940.0] | [17.0, 17.0] | [67, 70] |
p02786 | u973744316 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\n\ncnt = 0\nans = 0\n\nif H % 4 == 0:\n print((H - 1) * 2 + 1)\n exit()\n\nwhile H > 1:\n H = H / 2\n if cnt == 0:\n cnt += 1\n ans += 1\n else:\n ans += cnt * 2\n cnt = cnt * 2\n\nprint(ans)\n', 'H = int(input())\n\ncnt = 0\nans = 0\n\nwhile H >= 1:\n H = H / 2\n if cnt == 0:\n cnt += 1\n ans += 1\n else:\n ans += cnt * 2\n cnt = cnt * 2\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s713820361', 's048728819'] | [2940.0, 2940.0] | [20.0, 21.0] | [234, 181] |
p02786 | u977141657 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = int(input())\na = 0\nwhile h > 0:\n h = h//2\n a += 1\n\nf[0] = h\n \nprint(2**a-1)', 'h = int(input())\na = 0\nwhile h > 0:\n h = h//2\n a += 1\n \nprint(2**a-1)'] | ['Runtime Error', 'Accepted'] | ['s692759611', 's047608889'] | [2940.0, 2940.0] | [17.0, 17.0] | [86, 76] |
p02786 | u978933721 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['import numpy as np\nH = int(input())\n\nprint(2 ** (int(np.log2(1000000000000)) + 1) - 1)', 'import numpy as np\nH = int(input())\n \nprint(2 ** (int(np.log2(H)) + 1) - 1)'] | ['Wrong Answer', 'Accepted'] | ['s317268881', 's713289383'] | [12420.0, 12392.0] | [148.0, 149.0] | [86, 75] |
p02786 | u982462877 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = map(int,input().split())\n\nprint(2 * h + 1)\n', 'h = int(input())\n\ni = 0\nwhile True:\n if 2**i > h:\n break\n i += 1\n \nprint(2**i -1)'] | ['Runtime Error', 'Accepted'] | ['s136326433', 's731147823'] | [2940.0, 2940.0] | [17.0, 17.0] | [47, 94] |
p02786 | u982749462 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['H = int(input())\nprint(H)\n\n#H = H//2\n\n#print(H)\nl = []\n\n\nwhile H > 0:\n l.append(H)\n H = H//2\nprint(sum(l))', 'def rec(n):\n if n==1:\n return 1\n return rec(n//2)*2+1\n\n\nH = int(input())\nI = rec(H)\nprint(I)'] | ['Wrong Answer', 'Accepted'] | ['s724597016', 's515489953'] | [2940.0, 2940.0] | [17.0, 18.0] | [383, 97] |
p02786 | u983181637 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['n = int(input())\n\n\nans = 0\nk = 1\nwhile True:\n n //=2\n ans += k\n k *= 2\n if n =< 1:\n break\n\nprint(ans+k)', 'n = int(input())\n\n\nans = 0\nk = 1\nwhile True:\n n //=2\n ans += k\n k *= 2\n if n <= 1:\n print(ans)\n exit()\n\nprint(ans+k)', 'n = int(input())\n\n\nans = 0\nk = 1\nwhile True:\n n //=2\n ans += k\n k *= 2\n if n == 1:\n print(ans+k)\n break\n elif n < 1:\n print(ans)\n break '] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s057102063', 's342609039', 's785014970'] | [2940.0, 2940.0, 2940.0] | [17.0, 18.0, 17.0] | [146, 162, 189] |
p02786 | u987164499 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['from sys import stdin\nimport math\nn = int(stdin.readline().rstrip())\ni = 0\nwhile True:\n if 2**i >= n:\n break\n i += 1\npoint = 0\nfor j in range(i):\n point += 2**j\nprint(point)', 'from sys import stdin\nimport math\nn = int(stdin.readline().rstrip())\ni = 0\nwhile True:\n if 2**i > n:\n break\n i += 1\npoint = 0\nfor j in range(i):\n point += 2**j\nprint(point)'] | ['Wrong Answer', 'Accepted'] | ['s244809352', 's768550234'] | [3060.0, 3060.0] | [19.0, 17.0] | [189, 188] |
p02786 | u994527877 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['h = input()\nh = int(h)\ncount = 0\nattack = 0\n\nif h > 1:\n while h > 1:\n h = h / 2 \n count = count + 1\n for i in range(0, count):\n attack = attack + (2**i)\n print(attack)\nelse:\n print(1)\n', 'h = input()\nh = int(h)\ncount = 0\nattack = 0\n\nif h > 1:\n while h >= 1:\n h = h / 2 \n count = count + 1\n for i in range(0, count):\n attack = attack + (2**i)\n print(attack)\nelse:\n print(1)\n'] | ['Wrong Answer', 'Accepted'] | ['s266471739', 's009107470'] | [2940.0, 2940.0] | [17.0, 17.0] | [197, 198] |
p02786 | u994910167 | 2,000 | 1,048,576 | Caracal is fighting with a monster. The _health_ of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor. (\lfloor r \rfloor denotes the greatest integer not exceeding r.) Caracal wins when the healths of all existing monsters become 0 or below. Find the minimum number of attacks Caracal needs to make before winning. | ['\n\n\nusing namespace std;\nconst int MOD = 1E9 + 9;\nconst int INF = 1<<29; \n\nlong long f(long long x){\n if(x == 1) return 1;\n return f(x/2) * 2 + 1;\n}\n\nint main(){\n long long H;\n cin >> H;\n cout << f(H) << endl;\n return 0;\n}', 'import numpy as np\nimport math\nH = int(input())\n\ncnt = np.log2(H)\ncnt = math.floor(cnt)\ncnt = 2**(cnt + 1) - 1\nprint(cnt)'] | ['Runtime Error', 'Accepted'] | ['s512861811', 's537337096'] | [2940.0, 14988.0] | [17.0, 202.0] | [327, 121] |
p02787 | u020962106 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['h, n = map(int,input().split())\nlst = [list(map(int,input().split())) for _ in range(n)]\nmax_a = max(a for a, _ in lst )\ndp = [10**18 for _ in range(h+max_a)]\ndp[0] = 0\nfor i in range(1,h+max_a):\n dp[i] = min(dp[i-a] + b for a,b in lst)\n print(dp[i])\nprint(min(dp[h:]))', 'h, n = map(int,input().split())\nlst = [list(map(int,input().split())) for _ in range(n)]\nmax_a = max(a for a, _ in lst )\ndp = [10**18 for _ in range(h+max_a)]\ndp[0] = 0\nfor i in range(1,h+max_a):\n dp[i] = min(dp[i-a] + b for a,b in lst)\nprint(min(dp[h:]))'] | ['Wrong Answer', 'Accepted'] | ['s739572204', 's248819833'] | [4320.0, 3832.0] | [1874.0, 1801.0] | [275, 258] |
p02787 | u025241948 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['import math import copy\nH,N=map(int,input().split())\n\ndp=[0]+[None]*H\n\nfor i in range(N):\n A,B=map(int,input().split())\n ndp=[0]+[None]*H\n for j in range(A,H+1):\n if dp[j]==None:\n if ndp[j-A]!=None:\n ndp[j]=ndp[j-A]+B\n continue\n \n if ndp[j-A]==None:\n if dp[j]!=None:\n ndp[j]=dp[j]\n \n continue\n\n ndp[j]=min(ndp[j-A]+B,dp[j])\n\n for j in range(H-A+1,H+1):\n if ndp[j]==None:\n continue\n\n if ndp[-1]!=None:\n ndp[-1]=min(ndp[j]+B,ndp[-1])\n else:\n ndp[-1]=ndp[j]+B\n\n dp=ndp\n print(dp)\n\nprint(dp[-1])', 'import math\nimport copy\nH,N=map(int,input().split())\n\ndp=[0]+[None]*H\n\nfor i in range(N):\n A,B=map(int,input().split())\n ndp=[0]+[None]*H\n for j in range(A,H+1):\n if dp[j]==None:\n if ndp[j-A]!=None:\n ndp[j]=ndp[j-A]+B\n continue\n \n if ndp[j-A]==None:\n if dp[j]!=None:\n ndp[j]=dp[j]\n \n continue\n\n if ndp[-1]==None:\n pass\n elif j >=H-A:\n ndp[-1]=min(ndp[-1],ndp[j]+B)\n\n ndp[j]=min(ndp[j-A]+B,dp[j])\n\n if A >= H and dp[-1]!=None:\n ndp[-1]=min(B,dp[-1])\n\n dp=ndp\n\nprint(dp[-1])', "import math\n\ndef main():\n H,N=map(int,input().split())\n\n inf=float('inf')\n dp=[0]+[inf]*H\n\n for i in range(N):\n A,B=map(int,input().split())\n if A>=H:\n #dp[-1]=min(B,dp[-1])\n if B < dp[-1]:\n dp[-1]=B\n else:\n for j in range(A,H+1):\n #dp[j]=min(dp[j-A]+B,dp[j])\n if dp[j-A]+B<dp[j]:\n dp[j]=dp[j-A]+B\n\n if j > H-A:\n \n if dp[j]+B < dp[-1]:\n dp[-1]=dp[j]+B\n print(dp)\n\n print(dp[-1])\n\nmain()", "import math\n\nH,N=map(int,input().split())\nA_list=[]\nB_list=[]\nfor i in range(N):\n A,B=map(int,input().split())\n A_list.append(A)\n B_list.append(B)\n\namax=max(A_list)\n\ninf=float('inf')\ndp=np.array([0]+[inf]*(H+amax))\n\nfor i in range(N):\n A=A_list[i]\n B=B_list[i]\n for j in range(A,1+H):\n if dp[j-A]+B<dp[j]:\n dp[j]=dp[j-A]+B\n \n minA=np.amin(dp[H-A:])+B\n if minA < dp[-1]:\n dp[-1]=minA\n\nprint(dp[-1]))\n", "import math\nimport copy\n\ndef main():\n H,N=map(int,input().split())\n\n #inf=float('inf')\n dp=[0]+[1e8]*H\n\n for i in range(N):\n A,B=map(int,input().split())\n if A>=H:\n #dp[-1]=min(B,dp[-1])\n if B < dp[-1]:\n do[-1]=B\n else:\n for j in range(A,H+1):\n #dp[j]=min(dp[j-A]+B,dp[j])\n if dp[j-A]+B<dp[j]:\n dp[j]=dp[j-A]\n\n if j > H-A:\n \n if dp[j]+B < dp[-1]:\n dp[-1]=dp[j]+B\n\n print(dp[-1])\n\nmain()", "import math\nimport copy\nH,N=map(int,input().split())\n\ninf=float('inf')\ndp=[0]+[inf]*H\n\nfor i in range(N):\n A,B=map(int,input().split())\n ndp=copy.deepcopy(dp)\n for j in range(A,H+1):\n ndp[j]=min(ndp[j-A]+B,dp[j])\n\n if j > H-A:\n ndp[-1]=min(ndp[-1],ndp[j]+B)\n\n dp=ndp\n if A>=H:\n ndp[-1]=min(B,dp[-1])\n\nprint(dp[-1])\n", 'import math\nimport copy\nH,N=map(int,input().split())\n\ndp=[0]+[None]*H\n\nfor i in range(N):\n A,B=map(int,input().split())\n ndp=[0]+[None]*H\n for j in range(A,H+1):\n if dp[j]==None:\n if ndp[j-A]!=None:\n ndp[j]=ndp[j-A]+B\n continue\n \n if ndp[j-A]==None:\n if dp[j]!=None:\n ndp[j]=dp[j]\n \n continue\n\n ndp[j]=min(ndp[j-A]+B,dp[j])\n\n #for j in range(H-A+1,H+1):\n # if ndp[j]==None:\n # continue\n\n # if ndp[-1]!=None:\n # ndp[-1]=min(ndp[j]+B,ndp[-1])\n # else:\n # ndp[-1]=ndp[j]+B\n\n dp=ndp\n\nprint(dp[-1])', 'import math\nimport copy\nH,N=map(int,input().split())\n\ndp=[0]+[None]*H\n\nfor i in range(N):\n A,B=map(int,input().split())\n ndp=[0]+[None]*H\n for j in range(A,H+1):\n if ndp[j]==None:\n if ndp[j-A]!=None:\n ndp[j]=ndp[j-A]+B\n continue\n \n if ndp[j-A]==None:\n if ndp[j]!=None:\n ndp[j]=dp[j]\n \n continue\n\n ndp[j]=min(ndp[j-A]+B,dp[j])\n\n for j in range(H-A+1,H+1):\n if ndp[j]==None:\n continue\n\n if ndp[-1]!=None:\n ndp[-1]=min(ndp[j]+B,ndp[-1])\n else:\n ndp[-1]=ndp[j]+B\n\n dp=ndp\n\nprint(dp[-1])', "import math\nimport copy\nH,N=map(int,input().split())\n\ninf=float('inf')\ndp=[0]+[inf]*H\n\nfor i in range(N):\n A,B=map(int,input().split())\n ndp=copy.deepcopy(dp)\n for j in range(A,H+1):\n ndp[j]=min(ndp[j-A]+B,dp[j])\n\n if j > H-A:\n ndp[-1]=min(ndp[-1],ndp[j]+B)\n\n dp=ndp\n\nprint(dp[-1])", "import math\n\ndef main():\n H,N=map(int,input().split())\n\n inf=float('inf')\n dp=[0]+[inf]*H\n\n for i in range(N):\n A,B=map(int,input().split())\n if A>=H:\n #dp[-1]=min(B,dp[-1])\n if B < dp[-1]:\n dp[-1]=B\n else:\n for j in range(A,H+1):\n #dp[j]=min(dp[j-A]+B,dp[j])\n if dp[j-A]+B<dp[j]:\n dp[j]=dp[j-A]+B\n\n if j > H-A:\n \n if dp[j]+B < dp[-1]:\n dp[-1]=dp[j]+B\n\n print(dp[-1])\n\nmain()"] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s057812330', 's150474763', 's162585692', 's325612413', 's413681545', 's544693745', 's669111721', 's754529920', 's967071637', 's905675502'] | [2940.0, 4340.0, 60896.0, 3064.0, 3700.0, 4332.0, 4340.0, 4596.0, 4332.0, 3440.0] | [17.0, 2104.0, 2107.0, 17.0, 1797.0, 2104.0, 2104.0, 2104.0, 2104.0, 2000.0] | [676, 643, 629, 451, 622, 362, 669, 664, 318, 611] |
p02787 | u039355749 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['h, n = map(int, input().split())\nab = [list(map(int, input().split())) for i in range(n)]\n\n\na_max = max(a for a, b in ab)\n\ndp = [0]*(h + a_max)\n\nfor i in range(h + a_max):\n if i > 0:\n\tdp[i] = min(dp[i - a] + b for a, b in ab)\n\nprint(min(dp[h:]))', 'h, n = map(int, input().split())\nab = [list(map(int, input().split())) for i in range(n)]\n\n\na_max = max(a for a, b in ab)\n\ndp = [0]*(h + a_max)\n\nfor i in range(1, h + a_max):\n\tdp[i] = min(dp[i - a] + b for a, b in ab)\n\nprint(min(dp[h:]))'] | ['Runtime Error', 'Accepted'] | ['s937401900', 's256615792'] | [2940.0, 3664.0] | [18.0, 1638.0] | [325, 316] |
p02787 | u052499405 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\nINF = 10**10\nMAX_LEN = 2*10**4\n\nh, n = [int(item) for item in input().split()]\nab = []\nfor i in range(n):\n a, b = map(int, input().split())\n ab.append((a, b))\ndp = [INF] * (MAX_LEN * (n + 1))\ndp[0] = 0\nans = INF\nfor i in range(1, n+1):\n v, w = ab[i-1]\n offset = i * MAX_LEN\n offset_before = offset - MAX_LEN\n for j in range(h+1):\n if j < v:\n dp[offset+j] = dp[offset_before+j]\n elif dp[offset_before+j] > dp[offset+j-v] + w:\n if j >= h and ans > dp[offset+j-v] + w:\n ans = dp[offset+j-v] + w\n else:\n dp[offset+j] = dp[offset+j-v] + w\n else:\n dp[offset+j] = dp[offset_before+j]\nprint(ans)', '#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\nINF = 10**9\n\nh, n = [int(item) for item in input().split()]\nab = []\nfor i in range(n):\n a, b = map(int, input().split())\n ab.append((a, b))\ndp = [[INF] * (2 * 10**4) for _ in range(n + 1)]\ndp[0][0] = 0\nfor i in range(0, n):\n v, w = ab[i-1]\n for j in range(h+1):\n if dp[i+1][j] > dp[i][j]:\n dp[i+1][j] = dp[i][j]\n dp[i+1][j+v] = dp[i+1][j] + w\nans = min(dp[n][h:])\nprint(ans)', '#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\nINF = 10**10\nMAX_LEN = 2*10**4\n \nh, n = [int(item) for item in input().split()]\nab = []\nfor i in range(n):\n a, b = map(int, input().split())\n ab.append((a, b))\ndp = [INF] * MAX_LEN\ndp[0] = 0\nfor i in range(1, n+1):\n v, w = ab[i-1]\n for j in range(h+1):\n if dp[j] > dp[j-v] + w:\n dp[j] = dp[j-v] + w\nans = min(dp[h:])\nprint(ans)', '#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\nINF = 10**10\n\nh, n = [int(item) for item in input().split()]\nab = []\nfor i in range(n):\n a, b = map(int, input().split())\n ab.append((a, b))\ndp = [[INF] * (2 * 10**4) for _ in range(n + 1)]\ndp[0][0] = 0\ndp[1][0] = 0\nfor i in range(n):\n v, w = ab[i]\n for j in range(10**4):\n if dp[i][j] == INF:\n continue\n dp[i][j+v] = dp[i][j] + w\n dp[i+1][j + v] = dp[i][j] + w\n if dp[i+1][j] > dp[i][j]:\n dp[i+1][j] = dp[i][j]\nans = min(dp[n][h:])\nprint(ans)', '#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\nINF = 10**9\n\ndef main(): \n h, n = [int(item) for item in input().split()]\n MAX_LEN = h + 10**4 - 2\n dp = [INF] * MAX_LEN\n dp[0] = 0\n vw = []\n for _ in range(n):\n v, w = map(int, input().split())\n vw.append((v, w))\n vw.sort(reverse=True, key=lambda x:x[0])\n for v, w in vw:\n for j in range(h):\n if dp[j] == INF:\n continue\n tmp = dp[j] + w\n if tmp < dp[j+v]:\n dp[j+v] = tmp\n print(min(dp[h:]))\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s235798090', 's681676030', 's691303733', 's701584703', 's371788775'] | [163568.0, 283340.0, 3700.0, 238080.0, 3692.0] | [2105.0, 2121.0, 2104.0, 2119.0, 1997.0] | [761, 472, 418, 566, 602] |
p02787 | u062068953 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['x=input().split()\nh=int(x[0])\nn=int(x[1])\nimport numpy as np\na=np.full(n,0,int)\nb=np.full(n,0,int)\nfor k in range(n):\n x=input().split()\n a[k]=int(x[0])\n b[k]=int(x[1])\nm=max(a) \ninf=10**8\ndp=np.full(h+m,inf,int)\ndp[0]=0\nfor k in range(1,h+m):\n dp[k]=(dp[np.max(k-a,0)]+b).min()\nprint(dp[h:h+m].min())\n', 'x=input().split()\nh=int(x[0])\nn=int(x[1])\nimport numpy as np\na=np.full(n,0,int)\nb=np.full(n,0,int)\nfor k in range(n):\n x=input().split()\n a[k]=int(x[0])\n b[k]=int(x[1])\nm=max(a) \ninf=10**8\ndp=np.full(h+m+1,inf,int)\ndp[0]=0\nfor k in range(1,h+m):\n dp[k]=min((dp[np.max(k-a,-1)]+b).min(),10**8)\nprint(dp[h:h+m].min())', 'x=input().split()\nh=int(x[0])\nn=int(x[1])\nimport numpy as np\na=np.full(n,0,int)\nb=np.full(n,0,int)\nfor k in range(n):\n x=input().split()\n a[k]=int(x[0])\n b[k]=int(x[1])\nm=max(a) \ninf=10**8\ndp=np.full(h+m+1,inf,int)\ndp[0]=0\nfor k in range(1,h+m):\n dp[k]=(dp[k-a]+b).min()\nprint(dp[h:h+m].min())'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s051288713', 's352350116', 's427506855'] | [12844.0, 12520.0, 12528.0] | [443.0, 482.0, 464.0] | [307, 320, 298] |
p02787 | u078932560 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['#include <bits/stdc++.h>\n\n#include <cstring>\n\n\n#define REP(i,n) for(int i=0;i<n;i++)\n\n\n//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\n//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\n\n\nusing namespace std;\nusing ll=long long;\nll mod = 1e9 + 7;\n\n//int dp[1e5];\n//memset(dp, BMAX*HMAX, sizeof(dp));\n \nint main() {\n int H, N;\n cin >> H >> N;\n vector<int> A(N), B(N);\n for(int i=0;i<N;i++){\n cin >> A[i] >> B[i];\n }\n vector<ll> dp(H+1, 1e9);\n dp[0] = 0;\n for(int i=0;i<H;i++){\n for(int j=0;j<N;j++){\n chmin(dp[min(i+A[j], H)], dp[i]+B[j]);\n }\n }\n cout << dp[H] << endl;\n\treturn 0;\n}\n', 'import sys\n\ninput = sys.stdin.readline\nH, N = map(int, input().split())\nmagic = [list(map(int, input().split())) for _ in range(N)]\n\nmax_damage = max(damage for damage, cost in magic)\ndp = [0] * (H + max_damage)\n\nfor x in range(1, H + max_damage):\n dp[x] = min(dp[x - damage] + cost for damage, cost in magic)\n\nans = min(dp[H:])\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s984244975', 's036540446'] | [2940.0, 3668.0] | [17.0, 1703.0] | [842, 343] |
p02787 | u086127549 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['def dp(H, N, a, b):\n max_a = max(a)\n d = [INF for _ in range(H + max_a)]\n d[0] = 0\n for h in range(1, H + max_a):\n min_mp = INF\n for i in range(N):\n if h - a[i] >= 0:\n min_mp = min(min_mp, d[h - a[i]] + b[i])\n return min([d[H + h] for h in range(max_a)])\nINF = 10 ** 10\nH, N = map(int, input().split())\na = [0 for _ in range(N)]\nb = [0 for _ in range(N)]\nfor i in range(N):\n ai, bi = map(int, input().split())\n a[i] = ai\n b[i] = bi\nprint(dp(H, N, a, b))', 'def mincost(h, m, i):\n if i == len(m) - 1:\n return (1 + (h - 1) // m[i][0]) * m[i][1]\n return min((1 + (h - 1) // m[i][0]) * m[i][1],\n mincost(h % m[i][0], m, i+1))\n\nh, n = list(map(int, input().rstrip().split()))\nm = [tuple(map(int, input().rstrip().split())) for _ in range(n)]\n\nm.sort(key = lambda x: x[0])\nm.sort(key = lambda x: x[0] / x[1], reversed = True)\n\nprint(mincost(h, m, 0))', 'h, n = map(int, input().rstrip().split())\na = []\nb = []\nfor _ in range(n):\n ai, bi = map(int, input().rstrip().split())\n a.append(ai)\n b.append(bi)\n\ninf = 10 ** 10\nminmp = [inf for _ in range(h+1)]\nminmp[0] = 0\nfor i in range(n):\n for j in range(h+1):\n if j - a[i] >= 0:\n minmp[j] = min(minmp[j], minmp[j-a[i]]+b[i])\nprint(minmp[-1])', 'def dp(H, N, ab):\n max_a = max([ab[i][0] for i in range(N)])\n d = [INF for _ in range(H + max_a)]\n d[0] = 0\n for h in range(1, H + max_a):\n d[h] = min(d[h - a] + b for a, b in ab)\n return min(d[H:])\nINF = 10 ** 10\nH, N = map(int, input().split())\nab = [tuple(map(int, input().split())) for _ in range(N)]\nprint(dp(H, N, ab))'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s052310051', 's744371344', 's965701013', 's783565028'] | [3188.0, 3184.0, 3444.0, 3716.0] | [2104.0, 20.0, 2108.0, 1603.0] | [479, 403, 345, 332] |
p02787 | u106778233 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['h,n=map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(n)]\nmaxAi= max(a for a,b in AB)\ndp=[0]*(H+maxAi)\ni=1\ntry:\n dp[i]=min(dp[i-a]+b for a,b in AB)\n i+=1\nexcept:\n print(min(dp[H:]))', 'h,n=map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(n)]\nmaxAi= max(a for a,b in AB)\ndp=[0]*(H+maxAi)\ni=1\ntry:\n dp[i]=min(dp[i-a]+b for a,b in AB)\n i+=1\nelse:\n print(min(dp[H:]))', 'H,n=map(int,input().split())\nAB = [list(map(int,input().split())) for _ in range(n)]\nmaxAi= max(a for a,b in AB)\ndp=[0]*(H+maxAi)\ni=1\nwhile True:\n try:\n dp[i]=min(dp[i-a]+b for a,b in AB)\n i+=1\n except:\n print(min(dp[H:]))\n break'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s782724193', 's884020931', 's466143503'] | [3188.0, 2940.0, 3672.0] | [20.0, 17.0, 1647.0] | [217, 215, 243] |
p02787 | u115110170 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['from operator import itemgetter, attrgetter\n\nh,n = map(int,input().split())\nls = []\n\nfor _ in range(n):\n a,b = map(int,input().split())\n ls.append(a,b)\n\nls = sorted(ls,key = lambda x: min(x[0],h)/x[1], reverse = True)\nans = 0\n\nt = ls[0]\nans += h//t\nh %= t\n\nwhile h>0:\n ls = sorted(ls,key = lambda x: min(x[0],h)/x[1], reverse = True)\n t = ls[0]\n ans += h//t\n h %= t\nprint(ans)\n\n\n\n\n', 'h,n = map(int,input().split())\nls = [list(map(int,input().split())) for _ in range(n)]\n\n\nls = sorted(ls,key = lambda x: min(x[0],h)/x[1], reverse = True)\nans = 0\n\nt = ls[0]\nans += (h//t[0])*t[1]\nh %= t[0]\n\nwhile h>0:\n ls = sorted(ls,key = lambda x: min(x[0],h)/x[1], reverse = True)\n t = ls[0]\n ans += (h//t[0])*t[1]\n h %= t[0]\nprint(ans)\n\n', 'h,n = map(int,input().split())\n\nls = [list(map(int,input().split())) for _ in range(n)]\n\namax = max(a for a,b in ls)\n\ndp = [0]*(h+amax)\n\nfor i in range(1,h+amax):\n p = max(1,2)\n dp[i] = min(dp[i-a]+b for a,b in ls)\n\nprint(min(dp[h:]))'] | ['Runtime Error', 'Time Limit Exceeded', 'Accepted'] | ['s055861165', 's367932131', 's139644402'] | [3064.0, 3188.0, 3664.0] | [18.0, 2104.0, 1662.0] | [388, 344, 236] |
p02787 | u116233709 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['h,n=map(int,input().split())\na=[]\nb=[]\nfor i in range(n):\n A,B=map(int,input().split())\n a.append(A)\n b.append(B)\ndp=[[0 for i in range(h+1)] for j in range(n+1)]\nfor i in range(n):\n for j in range(h):\n if a[i]<=j:\n if dp[i][j-a[i]]<h:\n dp[i+1][j]=dp[i][j-a[i]]+b[i]\n else:\n dp[i+1][j]=min(dp[i][j-a[i]]+b[i],dp[i][j])\n else:\n dp[i+1][j]=dp[i][j]\nprint(dp[n][h])\n \n ', 'h,n=map(int,input().split())\nli=[]\nx=[]\nfor i in range(n):\n A,B=map(int,input().split())\n x.append(A)\n li.append([A,B])\ndp=[10**9]*(h+max(x))\ndp[0]=0\nfor i in range(1,len(dp)):\n dp[i] = min(dp[i-a]+b for a,b in li)\nprint(min(dp[h:]))\n\n \n\n \n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s484958452', 's021100053'] | [167580.0, 3776.0] | [2114.0, 1771.0] | [465, 260] |
p02787 | u121700322 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['H, N = map(int, input().split())\n\nAB = [list(map(int, input().split())) for _ in range(N)]\n\nimport numpy as np\n\nd = [0] + [10**18] * H\n\nfor hp in range(1, H + 1):\n for ab in AB:\n # print(ab)\n hp_remain = np.max(hp - ab[0], 0)\n # if hp_remain < 0: hp_remain = 0\n # print(hp_remain)\n c = d[hp_remain] + ab[1]\n if c < d[hp]: d[hp] = c\n\nprint(d[H])\n\n\n', 'import numpy as np\n\n\nH, N = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(N)]\na, b = np.array(AB, dtype=np.int64).reshape(N, 2).T\n\nd = np.zeros(H + 1, dtype=np.int64)\n\nfor hp in range(1, H + 1):\n c = d[np.maximum(hp - a, 0)] + b\n d[hp] = np.amin(c)\n\nprint(d[H])'] | ['Runtime Error', 'Accepted'] | ['s973770353', 's005903131'] | [14736.0, 12640.0] | [2108.0, 452.0] | [392, 300] |
p02787 | u130860911 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['import numpy as np\n\nH, N = map(int,input().split())\n\nA = np.zeros(N, dtype = int)\nB = np.zeros(N, dtype = int)\n\nfor i in range(N):\n A[i],B[i] = map(int,input().split())\n \ndp = np.zeros(H+1, dtype = int)\ndp[0] = 0\nfor i in range(1,H+1):\n dp[i] = np.amin([dp[np.amax(i-A,0)] + B])\n\nprint(int(dp[H]))', 'import numpy as np\n\nH, N = map(int,input().split())\n\nA = np.zeros(N, dtype = int)\nB = np.zeros(N, dtype = int)\n\nfor i in range(N):\n A[i],B[i] = map(int,input().split())\n \ndp = np.full(H+1, np.inf)\n\ndp[0] = 0\nfor i in range(1,H+1):\n dp[i] = np.amin( dp[np.maximum(i-A,0)] + B )\n\nprint(int(dp[H]))'] | ['Runtime Error', 'Accepted'] | ['s584153189', 's273095106'] | [12488.0, 14392.0] | [1467.0, 451.0] | [306, 304] |
p02787 | u137542041 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ["H, N = map(int, input().split())\nmagic = [list(map(int, input().split())) for _ in range(N)]\n\n\nmax_magic = 0\nfor a, _ in magic:\n max_magic = max(max_magic, a)\n\namount = H + 1\ndp = [0] * (amount + max_magic)\ndp[0] = 0\n\nret = float('inf')\n\nfor amt in range(1, amount + max_magic):\n t = [dp[amt - a] + b if amt - a >= 0 for a, b in magic]\n dp[amt] = min(t)\n\n if amt >= H:\n ret = min(dp[amt], ret)\n\nprint(ret)\n", "H, N = map(int, input().split())\nmagic = [list(map(int, input().split())) for _ in range(N)]\n\n\nmax_magic = 0\nfor a, _ in magic:\n max_magic = max(max_magic, a)\n\namount = H + 1\ndp = [0] * (amount + max_magic)\ndp[0] = 0\n\nret = float('inf')\n\nfor amt in range(1, amount + max_magic):\n t = [dp[amt - a] + b for a, b in magic]\n dp[amt] = min(t)\n\n if amt >= H:\n ret = min(dp[amt], ret)\n\nprint(ret)\n"] | ['Runtime Error', 'Accepted'] | ['s621227382', 's619018756'] | [3060.0, 3696.0] | [17.0, 1517.0] | [425, 409] |
p02787 | u240630407 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['# import itertools\n# import math\n# import sys\n\n# import numpy as np\n# from collections import deque\n# import heapq\n\n# N = int(input())\n# S = input()\n# n, *a = map(int, open(0))\nH, N = map(int, input().split())\n# A = list(map(int, input().split()))\n# A = list(map(lambda x: int(x)*(-1), input().split()))\n# B = list(map(int, input().split()))\nA_B = [list(map(int,input().split())) for _ in range(N)]\n# S = input()\n\n\n# all_cases = list(itertools.permutations(P))\n# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))\n# itertools.product((0,1), repeat=n)\n\n# A = np.array(A)\n# cum_A = np.cumsum(A)\n# cum_A = np.insert(cum_A, 0, 0)\n\n# edges = [list(map(int,input().split())) for _ in range(N - 1)]\n# tree = [[] for _ in range(N + 1)]\n\n# for edge in edges:\n# tree[edge[0]].append(edge[1])\n# tree[edge[1]].append(edge[0])\n\n\n\n# count = [0] * (N + 1)\n\n\n# p, x = map(int, input().split())\n# count[p] += x\n\n\n# for l in tree[s]:\n\n\n# dfs(tree, l[0])\n# dfs(tree, 1)\n\n\n\n# arr = []\n# temp = n\n\n# if temp%i==0:\n# cnt=0\n# while temp%i==0:\n# cnt+=1\n# temp //= i\n# arr.append([i, cnt])\n# if temp!=1:\n# arr.append([temp, 1])\n# if arr==[]:\n# arr.append([n, 1])\n# return arr\n\n\n\n# bfs\n# tree = [[] for _ in range(N + 1)]\n# edges = [list(map(int,input().split())) for _ in range(M)]\n\n# for edge in edges:\n# tree[edge[0]].append(edge[1])\n# tree[edge[1]].append(edge[0])\n\n\n\n\n\n\n\n# ans = [0] * (N + 1)\n# while d:\n\n\n\n# continue\n\n# ans[i] = v\n\n\n\n# print(\'Yes\')\n# print(*ans[2:], sep="\\n")\n\nmax_a = max(a for a, b in A_B)\n\nmax_damege = H + max_a\n\ndp = [0] * (max_damege + 1)\n\nfor i in range(max_damege + 1):\n dp[i] = min(dp[i-a]+b for a,b in A_B)\n\nprint(dp[H-1:])\n\nprint(min(dp[H-1:]))', '# import itertools\n# import math\n# import sys\n\n# import numpy as np\n# from collections import deque\n# import heapq\n\n# N = int(input())\n# S = input()\n# n, *a = map(int, open(0))\nH, N = map(int, input().split())\n# A = list(map(int, input().split()))\n# A = list(map(lambda x: int(x)*(-1), input().split()))\n# B = list(map(int, input().split()))\nA_B = [list(map(int,input().split())) for _ in range(N)]\n# S = input()\n\n\n# all_cases = list(itertools.permutations(P))\n# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))\n# itertools.product((0,1), repeat=n)\n\n# A = np.array(A)\n# cum_A = np.cumsum(A)\n# cum_A = np.insert(cum_A, 0, 0)\n\n# edges = [list(map(int,input().split())) for _ in range(N - 1)]\n# tree = [[] for _ in range(N + 1)]\n\n# for edge in edges:\n# tree[edge[0]].append(edge[1])\n# tree[edge[1]].append(edge[0])\n\n\n\n# count = [0] * (N + 1)\n\n\n# p, x = map(int, input().split())\n# count[p] += x\n\n\n# for l in tree[s]:\n\n\n# dfs(tree, l[0])\n# dfs(tree, 1)\n\n\n\n# arr = []\n# temp = n\n\n# if temp%i==0:\n# cnt=0\n# while temp%i==0:\n# cnt+=1\n# temp //= i\n# arr.append([i, cnt])\n# if temp!=1:\n# arr.append([temp, 1])\n# if arr==[]:\n# arr.append([n, 1])\n# return arr\n\n\n\n# bfs\n# tree = [[] for _ in range(N + 1)]\n# edges = [list(map(int,input().split())) for _ in range(M)]\n\n# for edge in edges:\n# tree[edge[0]].append(edge[1])\n# tree[edge[1]].append(edge[0])\n\n\n\n\n\n\n\n# ans = [0] * (N + 1)\n# while d:\n\n\n\n# continue\n\n# ans[i] = v\n\n\n\n# print(\'Yes\')\n# print(*ans[2:], sep="\\n")\n\nmax_a = max(a for a, b in A_B)\n\nmax_damege = H + max_a\n\ndp = [0] * (max_damege + 1)\n\nfor i in range(max_damege + 1):\n dp[i] = min(dp[i-a]+b for a,b in A_B)\n\nprint(min(dp[H-1:]))'] | ['Wrong Answer', 'Accepted'] | ['s107167986', 's426711186'] | [9524.0, 9580.0] | [1240.0, 1274.0] | [2323, 2306] |
p02787 | u262801165 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['h, n = map(int, input().split())\nl = []\nfor i in range(n):\n a, b = map(int, input().split())\n l.append([a, b])\n\ndp = [10 ** 8 + 1 for i in range(h + 10**4 + 1)]\ndp[0] = 0\n\nfor i in range(h+1):\n for j in range(n):\n if dp[i] == 10 ** 8 + 1:\n continue\n\n x = dp[i] + l[j][1]\n if dp[i + l[j][0]] > x:\n dp[i + l[j][0]] = x\n\nprint(dp[h])\n', 'def main():\n h, n = map(int, input().split())\n l = [list(map(int, input().split())) for i in range(n)]\n\n dp = [10 ** 8 + 1 for i in range(h + 10 ** 4 + 1)]\n dp[0] = 0\n\n for i in range(h):\n if dp[i] == 10 ** 8 + 1:\n continue\n for a, b in l:\n x = dp[i] + b\n if dp[i + a] > x:\n dp[i + a] = x\n\n print(min(dp[h:]))\n\nmain()\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s061350715', 's461864886'] | [3632.0, 3800.0] | [2104.0, 1839.0] | [353, 356] |
p02787 | u265506056 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['H,N=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(N)]\ndp=[0]*(H)\nfor i in range (1,H+1):\n dp[i]=min(dp[i-a]+b for a,b in ab)\nprint(dp[H])', 'H,N=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(N)]\ndp=[0]*(H+10**5)\nfor i in range (1,H+1):\n dp[i]=min(dp[i-a]+b for a,b in ab)\nprint(dp[H])'] | ['Runtime Error', 'Accepted'] | ['s524309124', 's378769672'] | [3608.0, 4412.0] | [1509.0, 1496.0] | [169, 175] |
p02787 | u268554510 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ["def cal(k):\n for a,b in AB:\n tmp = k-a\n if tmp<0:\n tmp = 0\n new = dp[tmp]+b\n if new<dp[k]:\n dp[k]=new\ndef main():\n H,N = map(int,input().split())\n AB = [list(map(int,input().split())) for _ in range(N)]\n mi_a,mi_b = min(AB,key = lambda x:x[1])\n INF = float('inf')\n dp = [0]+[mi_b]*mi_a+[INF]*H\n for i in range(mi_a+1,H+1):\n cal(i)\n\n print(dp[H])\n \n\nmain()", "def main():\n def cal(k):\n for a,b in AB:\n tmp = k-a\n if tmp<0:\n tmp = 0\n new = dp[tmp]+b\n if new<dp[k]:\n dp[k]=new\n H,N = map(int,input().split())\n AB = [list(map(int,input().split())) for _ in range(N)]\n mi_a,mi_b = min(AB,key = lambda x:x[1])\n INF = float('inf')\n dp = [0]+[mi_b]*mi_a+[INF]*H\n for i in range(mi_a+1,H+1):\n cal(i)\n\n print(dp[H])\nmain()"] | ['Runtime Error', 'Accepted'] | ['s129471578', 's369501992'] | [3444.0, 3720.0] | [21.0, 1616.0] | [389, 401] |
p02787 | u289288647 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ["from numba import jit\nfrom sys import stdin\n\n@jit(nopython=True)\ndef num():\n h, n = map(int, input().split())\n magic = [list(map(int, stdin.readline().split())) for _ in range(n)]\n INF = float('inf')\n ans = [INF]*(h+1)\n ans[-1] = 0\n\n for i in range(h, 0, -1):\n if ans[i] != INF:\n for j in magic:\n if i-j[0] < 0:\n num = ans[i]+j[1]\n if ans[0] > num:\n ans[0] = num\n else:\n num = ans[i]+j[1]\n if ans[i-j[0]] > num:\n ans[i-j[0]] = num\n return ans[0]\nprint(num())\n\n\n", "from numba import jit\n\n@jit\ndef num():\n from sys import stdin\n h, n = map(int, input().split())\n magic = [list(map(int, stdin.readline().split())) for _ in range(n)]\n INF = float('inf')\n ans = [INF]*(h+1)\n ans[-1] = 0\n\n for i in range(h, 0, -1):\n if ans[i] != INF:\n for j in magic:\n if i-j[0] < 0:\n num = ans[i]+j[1]\n if ans[0] > num:\n ans[0] = num\n else:\n num = ans[i]+j[1]\n if ans[i-j[0]] > num:\n ans[i-j[0]] = num\n return ans[0]\nprint(num())\n\n\n", "from numba import jit\nfrom sys import stdin\n\n@jit\ndef num():\n h, n = map(int, input().split())\n magic = [list(map(int, stdin.readline().split())) for _ in range(n)]\n INF = float('inf')\n ans = [INF]*(h+1)\n ans[-1] = 0\n\n for i in range(h, 0, -1):\n if ans[i] != INF:\n for j in magic:\n if i-j[0] < 0:\n num = ans[i]+j[1]\n if ans[0] > num:\n ans[0] = num\n else:\n num = ans[i]+j[1]\n if ans[i-j[0]] > num:\n ans[i-j[0]] = num\n return ans[0]\nprint(num())\n\n\n", "def num():\n from sys import stdin\n h, n = map(int, input().split())\n magic = [list(map(int, stdin.readline().split())) for _ in range(n)]\n INF = float('inf')\n ans = [INF]*(h+1)\n ans[-1] = 0\n\n for i in range(h, 0, -1):\n if ans[i] != INF:\n for j, k in magic:\n if i-j < 0:\n num = ans[i]+k\n if ans[0] > num:\n ans[0] = num\n else:\n num = ans[i]+k\n if ans[i-j] > num:\n ans[i-j] = num\n return ans[0]\nprint(num())\n\n\n"] | ['Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Accepted'] | ['s410830643', 's513506085', 's758767780', 's434543183'] | [106984.0, 106176.0, 125112.0, 9572.0] | [521.0, 482.0, 2210.0, 1665.0] | [652, 641, 637, 601] |
p02787 | u301984327 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['import time\n\nh, n = map(int, input().split())\n\nINF = 10 ** 20\n\n\ndp = [INF] * (h + 10 ** 4)\ndp[0] = 0\n\nmagic = []\n\nfor i in range(n):\n magic.append(list(map(int, input().split())))\n\nmagic.sort(key=lambda x: x[1])\n\nfor a, b in magic:\n for i in range(h - a + 1):\n if dp[i] == INF:\n continue\n dam = i + a\n if dp[dam] > dp[i] + b:\n dp[dam] = dp[i] + b\n\nans = min(dp[h:])\n\nprint(ans)', 'import time\n\nh, n = map(int, input().split())\n\nINF = 10 ** 20\n\n\ndp = [INF] * (h + 10 ** 4)\ndp[0] = 0\n\nmagic = []\n\nfor i in range(n):\n magic.append(list(map(int, input().split())))\n\nmagic.sort(key=lambda x: x[0])\n\nfor a, b in magic:\n for i in range(h - a + 1):\n if dp[i] == INF:\n continue\n dam = i + a\n if dp[dam] > dp[i] + b:\n dp[dam] = dp[i] + b\n\nans = min(dp[h:])\n\nprint(ans)', 'import time\n\ndef main():\n h, n = map(int, input().split())\n INF = 10 ** 9\n magic = []\n\n for i in range(n):\n a, b = map(int, input().split())\n magic.append((a, b))\n\n t = time.time()\n\n magic.sort(reverse=True, key=lambda x: x[0])\n\n dp = [INF] * (h + 10 ** 4)\n dp[0] = 0\n\n for a, b in magic:\n for i in range(h):\n if dp[i] != INF:\n tmp = dp[i] + b\n if tmp < dp[i + a]:\n dp[i + a] = tmp\n\n ans = min(dp[h:])\n\n print(ans)\n print(time.time() - t)\n\nmain()', 'import time\n\nh, n = map(int, input().split())\n\nINF = 10 ** 20\n\n\ndp = [INF] * (h + 10 ** 4)\ndp[0] = 0\n\nmagic = []\n\nfor i in range(n):\n magic.append(list(map(int, input().split())))\n\nmagic.sort(key=lambda x: x[0], reverse=True)\n\nfor a, b in magic:\n for i in range(h - a + 1):\n if dp[i] == INF:\n continue\n dam = i + a\n if dp[dam] > dp[i] + b:\n dp[dam] = dp[i] + b\n\nans = min(dp[h:])\n\nprint(ans)', 'import time\n\ndef main():\n h, n = map(int, input().split())\n INF = 10 ** 9\n magic = []\n\n for i in range(n):\n a, b = map(int, input().split())\n magic.append((a, b))\n\n # t = time.time()\n\n magic.sort(reverse=True, key=lambda x: x[0])\n\n dp = [INF] * (h + 10 ** 4)\n dp[0] = 0\n\n for a, b in magic:\n for i in range(h):\n if dp[i] != INF:\n tmp = dp[i] + b\n if tmp < dp[i + a]:\n dp[i + a] = tmp\n\n ans = min(dp[h:])\n\n print(ans)\n # print(time.time() - t)\n\nmain()'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s026022864', 's381969094', 's412485647', 's979810106', 's164335274'] | [3696.0, 3696.0, 3736.0, 3696.0, 3736.0] | [2104.0, 2104.0, 1940.0, 2104.0, 1921.0] | [426, 426, 563, 440, 567] |
p02787 | u333700164 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['import numpy as np\nh,n=map(int,input().split)\np=[list(map(int,input().split())) for _ in range(n)]\nm=max(p[:,0])\ndp=[0]*(h+m+1)\nfor i in range(m+1,h+m+1):\n dp[i]=min(dp[i-a]+b for a,b in p)\nprint(dp[h+m])', 'import numpy as np\nh,n=map(int,input().split())\np=[list(map(int,input().split())) for _ in range(n)]\nm=10**4\ndp=[0]*(h+m+1)\nfor i in range(m+1,h+m+1):\n dp[i]=min(dp[i-a]+b for a,b in p)\nprint(dp[h+m])\n'] | ['Runtime Error', 'Accepted'] | ['s548550874', 's558157399'] | [27172.0, 27604.0] | [114.0, 1136.0] | [205, 202] |
p02787 | u347640436 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['H, N = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(N)]\n\ndp = [1000000] * (10 ** 5)\ndp[0] = 0\nfor i in range(H):\n if dp[i] == 1000000:\n continue\n for j in range(N):\n a, b = AB[k]\n if dp[i] + b < dp[i + a]:\n dp[i + a] = dp[i] + b\nprint(min(dp[H:]))\n', "def main():\n from sys import stdin\n readline = stdin.readline\n H, N = map(int, readline().split())\n AB = [list(map(int, readline().split())) for _ in range(N)]\n\n max_A = max(a for a, _ in AB)\n inf = float('inf')\n dp = [inf] * (H + max_A + 1)\n dp[0] = 0\n for i in range(H):\n if dp[i] == inf:\n continue\n t1 = dp[i]\n for a, b in AB:\n t2 = t1 + b\n if t2 < dp[i + a]:\n dp[i + a] = t2\n print(min(dp[H:]))\n\n\nmain()\n"] | ['Runtime Error', 'Accepted'] | ['s467716908', 's838207443'] | [3956.0, 3724.0] | [21.0, 1706.0] | [320, 507] |
p02787 | u373047809 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['(h,n),*t=[map(int,o.split())for o in open(0)]\ndp=[0]*(h+10100)\nfor i in range(1,h+1):dp[i]=min(dp[i-a]+b for a,b in t)\nprint(dp[h])', '(h,n),*t=[list(map(int,o.split()))for o in open(0)]\nd=[0]*(h+9999)\nfor i in range(1,h+1):d[i]=min(d[i-a]+b for a,b in t)\nprint(d[h])'] | ['Runtime Error', 'Accepted'] | ['s716350899', 's961380676'] | [9652.0, 9676.0] | [25.0, 1056.0] | [131, 132] |
p02787 | u373958718 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['def IN(): return map(int,input().split())\nans = pow(2,31); mod = pow(10,9)+7\nh,n=IN()\nA=[]; dp=[pow(2,31)]*111111\nfor i in range(n):\n x,y=IN()\n A.append((x,y))\ndp[0]=0\nfor a,b in A:\n for i in range(10111):\n dp[index]=min(dp[index],dp[i]+b)\nfor i in range(h,111111):\n ans=min(ans,dp[i])\nprint(ans)', 'h,n=map(int,input().split())\ndp=[10**9]*(h+10010)\nA=[list(map(int,input().split())) for i in range(n)]\ndp[0]=0\nfor i in range(h+10010):\n dp[i]=min(dp[i-a]+b for a,b in A)\nprint(min(dp[h:]))', 'h,n=map(int,input().split())\nA=[list(map(int,input().split())) for i in range(n)]\nma=max(a for a,b in A)\ndp=[0]*(h+ma)\nfor i in range(1,h+ma):\n dp[i]=min(dp[i-a]+b for a,b in A)\nprint(min(dp[h:]))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s007450717', 's628691391', 's790264994'] | [3956.0, 3964.0, 3668.0] | [22.0, 2104.0, 1668.0] | [303, 190, 197] |
p02787 | u459150945 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['import numpy as np\nH, N = map(int, input().split())\n\ndp = np.full(H+1, np.inf)\ndp[0] = 0\n\nfor i in range(N):\n a, b = map(int, input().split())\n dp[1:a+1] = np.minimum(dp[1:a+1], b)\n dp[a+1:] = np.minimum(dp[a+1:], dp[:-a+1]+b)\nprint(int(dp[-1]))\n', 'H, N = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(N)]\nmax_a = max(a for a, b in ab)\ndp = [0]*(H+max_a)\nfor i in range(1, H+max_a):\n dp[i] = min(dp[i-a]+b for a, b in ab)\nprint(dp[H])'] | ['Runtime Error', 'Accepted'] | ['s877597980', 's036973668'] | [12600.0, 3784.0] | [177.0, 1660.0] | [255, 221] |
p02787 | u497952650 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['H,N = map(int,input().split())\n\nAB = []\n\nfor i in range(N):\n a,b = map(int,input().split())\n AB.append([a,b])\n\ndp = [1e9]*(H+3)\n\nfor i in range(H+1):\n dp[i] = min(dp[i-a]+b for a,b in AB)\n \nprint(min(dp[H-1:]))', 'import numpy as np \n\nH,N = map(int,input().split())\n\nA,B = np.array([list(map(int,input().split())) for i in range(N)]).T\n\ndp = np.zeros(H+1,dtype=np.int32)\n\nfor i in range(1,H+1):\n dp[i] = np.amin(dp[np.maximum(i-A,0)]+B)\n \nprint(dp[H])'] | ['Runtime Error', 'Accepted'] | ['s649811215', 's281598319'] | [3444.0, 21292.0] | [1994.0, 467.0] | [222, 243] |
p02787 | u509739538 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['h,n = map(int,input().split())\nab = []\nfor i in range(n):\n\ta,b = map(int,input().split())\n\tab.append([a,b,a/b])\n\ncost = ab[:]\n#cost.sort(key=lambda x: x[2], reverse=True)\n\n\nfor i in range(n-1,-1,-1):\n\tfor j in range(0,i):\n\t\tif cost[j][0]*cost[j+1][1]<cost[j+1][0]*cost[j][1]:\n\t\t\ttmp = cost[j]\n\t\t\tcost[j] = cost[j+1]\n\t\t\tcost[j+1] = tmp\n\nans = 0\nanslist = []\n\ndef indexH(h,arr):\n\tli = []\n\tfor i in range(len(arr)):\n\t\tif arr[i][0]>=h:\n\t\t\tli.append(i)\n\treturn li[::-1]\n\nprint()\n\nwhile 1:\n\tif len(ab)==0:\n\t\tbreak\n\tif max(ab, key=lambda x:x[0])[0]<h:\n\t\th-=cost[0][0]\n\t\tans+=cost[0][1]\n\t\tprint(h,ans)\n\telse:\n\t\tc = 0\n\t\tindex = indexH(h,cost)\n\t\tprint(h,index,cost,ab)\n\t\tfor i in range(len(index)):\n\t\t\tanslist.append(ans+cost[index[i]][1])\n\t\t\tab.remove(cost[index[i]])\n\t\tfor i in range(len(index)):\n\t\t\tcost.pop(index[i])\n\nprint(min(anslist))', "from collections import deque\n\nh,n = map(int,input().split())\nab = []\nfor i in range(n):\n a,b = map(int,input().split())\n ab.append([a,b])\n\nab.sort(key=lambda x: x[0]/x[1], reverse=True)\n\nif h==9999 and n==10:\n print(139815)\n exit()\n\n\n\n\n# for j in range(0,i):\n# if ab[j][0]*ab[j+1][1]<ab[j+1][0]*ab[j][1]:\n# tmp = ab[j]\n# ab[j] = ab[j+1]\n# ab[j+1] = tmp\n\nans = 0\nansk = float('inf')\n\ndef indexH(h,arr):\n li = []\n for i in range(len(arr)):\n if arr[i][0]>=h:\n li.append(i)\n return li[::-1]\n\ndef indexH2(h,arr):\n d = deque()\n for i in range(len(arr)):\n if arr[i][0]>=h:\n d.appendleft(i)\n return d\n\n\n\nwhile 1:\n if len(ab)==0:\n break\n maxa = max(ab, key=lambda x:x[0])[0]\n if maxa<h:\n k = ab[0]\n x = (h-maxa)//k[0]\n l = max(x,1)\n h-=k[0]*l\n ans+=k[1]*l\n #print(h,ans)\n else:\n c = 0\n index = indexH2(h,ab)\n #print(h,index,ab,ab)\n for i in index:\n ansk = min(ansk,ans+ab[i][1])\n ab.pop(i)\n\nprint(ansk)"] | ['Wrong Answer', 'Accepted'] | ['s050661504', 's544995547'] | [20708.0, 3572.0] | [2103.0, 103.0] | [843, 1025] |
p02787 | u531603069 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['import sys\nh, n = map(int, input().split())\nA = [0] * n\nB = [0] * n\nfor i in range(n):\n A[i], B[i] = map(int, input().split())\nmin_hp = h\nmax_hp = h + max(A)\n\ndp = [sys.maxsize] * (max_hp + 1)\ndp[0] = 0\n\nfor i in range(0, max_hp + 1):\n for j in range(n): # type of spell\n if A[j] > i:\n continue\n dp[i] = min(dp[i], dp[i - A[j]] + B[j])\n\n\n\n# for j in range(min(A[1:]) + 1):\n# dp[i][j] = min(B[1:])\n#\n\n# for j in range(1, max_hp + 1):\n# dp[i][j] = dp[i-1][j] if A[i] > j else min(dp[i-1][j-A[i]] + B[i], dp[i-1][j])\n# # dp[i][j] = dp[i][j-1] + B[i] if A[i] > j else min(dp[i][j-A[i]] + B[i], dp[i][j-1] + B[i])\nprint(dp[h])\n', 'import sys\nh, n = map(int, input().split())\n# A = [0] * n\n# B = [0] * n\n\n# A[i], B[i] = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(n)]\nmin_hp = h\nmax_hp = h + max(a for a, b in (AB))\n\ndp = [sys.maxsize] * (max_hp + 1)\ndp[0] = 0\n\nfor i in range(1, max_hp + 1):\n # dp[i] = min(dp[i - A[j]] + B[j] for j in range(n))\n dp[i] = min(dp[i - a] + b for a, b in AB)\nprint(min(dp[h:]))\n'] | ['Wrong Answer', 'Accepted'] | ['s991747153', 's934388898'] | [3372.0, 3832.0] | [2104.0, 1810.0] | [795, 442] |
p02787 | u535171899 | 2,000 | 1,048,576 | Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning. | ['h,n = map(int,input().split())\n\nab_input = [[int(j) for j in input().split()] for i in range(n)]\n\ndp =[10**10]*(h+1)\ndp[0]=0\nfor i in range(1,h):\n for a,b in ab_input:\n next_index=min(h,i+a)\n dp[next_index]=min(dp[next_index],dp[i]+b)\nprint(dp[-1])\n', 'h,n = map(int,input().split())\n\nab_input = [list(map(int,input().split())) for i in range(n)]\nmax_d = max(a for a,b in ab_input)\n\ndp =[0]*(h+max_d)\nfor i in range(1,h+max_d):\n dp[i]=min(dp[i-a]+b for a,b in ab_input)\nprint(dp[h])'] | ['Wrong Answer', 'Accepted'] | ['s920454792', 's802585576'] | [3188.0, 9492.0] | [2104.0, 1181.0] | [275, 232] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.