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
p02787
u545221414
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\n\ndp = [100000000] * (H + 10 ** 4 + 1)\n\n\nfor i in range(H):\n if dp[i] == 100000000:\n continue\n for a, b in AB:\n \n t = dp[i] + b\n \n if t < dp[i + a]:\n dp[i + a] = t\n\nprint(min(dp[H:]))\n\n\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 dp = [100000000] * (H + 10 ** 4 + 1)\n dp[0] = 0\n for i in range(H):\n if dp[i] == 100000000:\n continue\n for a, b in AB:\n t = dp[i] + b\n if t < dp[i + a]:\n dp[i + a] = t\n print(min(dp[H:]))\n\n\nmain()\n']
['Wrong Answer', 'Accepted']
['s891292719', 's540142596']
[3444.0, 3800.0]
[22.0, 1827.0]
[450, 445]
p02787
u563676207
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\n# input\nH, N = map(int, input().split())\n\nAB = [list(map(int, input().split())) for _ in range(N)]\nA, B = np.array(AB).reshape(N, 2).T\n\n# process\ndp = np.zeros(H+1)\ndp[0] = 0\n\nfor i in range(1, H + 1):\n dp[i] = np.amin(dp[np.maximum(i - A, 0)] + B)\n\n# output\nprint(dp[H])\n', '# input\nH, N = map(int, input().split())\nA = []\nB = []\nfor _ in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\n\n# process\nmax_a = max(A)\ndp = [10**9]*(H+max_a)\ndp[0] = 0\n\nfor i in range(len(dp)):\n if dp[i] == 10**4:\n continue\n for j in range(N):\n idx = i+A[j]\n if idx < len(dp) and dp[i]+B[j] < dp[idx]:\n dp[i+A[j]] = dp[i]+B[j]\n\nprint(dp)\n\n# output\nprint(min(dp[H:]))\n', 'import numpy as np\n\n# input\nH, N = map(int, input().split())\n\nAB = [list(map(int, input().split())) for _ in range(N)]\nA, B = np.array(AB, dtype=np.int64).reshape(N, 2).T\n\n# process\ndp = np.zeros(H+1, dtype=np.int64)\ndp[0] = 0\n\nfor i in range(1, H + 1):\n dp[i] = np.amin(dp[np.maximum(i - A, 0)] + B)\n\n# output\nprint(dp[H])\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s725269056', 's759485989', 's652852483']
[17444.0, 3684.0, 12612.0]
[450.0, 2104.0, 447.0]
[295, 439, 327]
p02787
u586662847
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\nimport numpy as np\n\n\nH, N = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(N)]\n\nAB.sort()\n\nans = 0\ndp = np.zeros(H, dtype=int)\nfor a, b in AB:\n ans = max(ans, dp.max() + b)\n np.max(dp[:-a] + b, dp[a:], out=dp[a:])\n\nprint(ans)\n', 'import sys\nimport numpy as np\n\nh, n = map(int, input().split())\nab = np.array(sys.stdin.read().split(), dtype=np.int64)\naaa = ab[0::2]\nbbb = ab[1::2]\n\ndp = np.zeros(10001, dtype=np.int64)\nfor i in range(1, h + 1):\n dp[i] = (dp[i - aaa] + bbb).min()\nprint(dp[h])\n']
['Runtime Error', 'Accepted']
['s736660183', 's455688744']
[12640.0, 14548.0]
[153.0, 421.0]
[297, 265]
p02787
u619455726
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.
["# -*- coding: utf-8 -*-\nimport numpy\nimport sys\nfrom functools import lru_cache\nsys.setrecursionlimit(10**6)\n\nh,n=map(int, input().split()) \nAB = [tuple(map(int, input().split())) for _ in range(n)]\n\nAB.sort(key=lambda ab: (ab[1] / ab[0], ab[0]))\n\n@lru_cache(maxsize=None)\ndef dp(h):\n if h <= 0:\n return 0\n else:\n best = float('inf')\n print(h)\n for a, b in AB:\n mp = b + dp(h -a)\n if mp < best:\n best = mp\n else:\n break\n return best\n\nprint(dp(h))", "# -*- coding: utf-8 -*-\nimport numpy\nimport sys\nfrom functools import lru_cache\nsys.setrecursionlimit(10**6)\n\nh,n=map(int, input().split()) \nAB = [tuple(map(int, input().split())) for _ in range(n)]\n\nAB.sort(key=lambda ab: (ab[1] / ab[0], ab[0]))\n\n@lru_cache(maxsize=None)\ndef dp(h):\n if h <= 0:\n return 0\n else:\n best = float('inf')\n for a, b in AB:\n mp = b + dp(h -a)\n if mp < best:\n best = mp\n else:\n break\n return best\n\nprint(dp(h))"]
['Wrong Answer', 'Accepted']
['s428779333', 's522356919']
[38740.0, 38740.0]
[216.0, 201.0]
[652, 635]
p02787
u638282348
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())\nATK, MP = zip(*(tuple(map(int, input().split())) for _ in range(N)))\ntable = [float("inf")] * (H + 1 + max(ATK))\ntable[0] = 0\nfor damage in range(1, H + 1):\n table[damage] = min(table[damage - ATK[magic]] + MP[magic] for magic in range(N))\nprint(table[H])\n', 'import numpy as np\nH, N = map(int, input().split())\nATK, MP = np.array(tuple(tuple(map(int, input().split())) for _ in range(N)), dtype=np.int32).T\ntable = np.zeros((H + ATK.max(),), dtype=np.int32)\nfor damage in range(1, H + 1):\n table[damage] = (table[damage - ATK] + MP).min()\nprint(table[H])\n']
['Wrong Answer', 'Accepted']
['s983344499', 's769586364']
[3476.0, 13068.0]
[2104.0, 439.0]
[292, 299]
p02787
u638456847
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\ndef main():\n H,N = map(int, input().split())\n A = [None]*N\n B = [None]*N\n for i in range(N):\n A[i], B[i] = map(int, input().split())\n \n dp = [float("inf")] * (H+1)\n dp[-1] = 0\n\n for i in range(N):\n for j in reversed(range(H+1)):\n if j - A[i] >= 0:\n dp[j-A[i]] = min(dp[j-A[i]], dp[j]+B[i])\n\n print(dp[0])\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\nimport numpy as np\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef main():\n H, N, *ab = map(int, read().split())\n A = []\n B = []\n for a, b in zip(*[iter(ab)] * 2):\n A.append(a)\n B.append(b)\n\n A = np.array(A)\n B = np.array(B)\n \n dp = np.full((H+1), np.inf)\n dp[0] = 0\n\n\n for i in range(1,H+1):\n dp[i] = np.min(dp[np.maximum(i - A, 0)] + B)\n\n print(int(dp[H]))\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s186791498', 's804661804']
[12472.0, 12504.0]
[2108.0, 438.0]
[432, 505]
p02787
u678167152
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\nC = [0]*N\nfor i in range(N):\n a,b = map(int, input().split())\n cp = b/a\n C[i]=[a,b,b/a]\n\nprint(C)\ndef battle(hp,magic):\n print(hp,magic,end=' ')\n if hp==0:\n return magic\n for i,[a,b,cp] in enumerate(C):\n if a>hp:\n C[i][0]=hp\n C[i][2]=b/hp\n C.sort(key=lambda x:x[2])\n print(*C[0])\n a,b,cp = C[0]\n num = hp//a\n hp -= a*num\n magic += b*num\n return battle(hp,magic)\n\nmagic = 0\nans = battle(H,magic)\nprint(ans)", 'import numpy as np\nimport numba\nfrom numba import njit, b1, i4, i8, f8\n\n@njit((i8,i8,i8[:],i8[:]), cache=True)\ndef main(H,N,A,B):\n INF = 1<<30\n dp = np.full(H+1,INF,np.int64)\n dp[0] = 0\n for i in range(N):\n for h in range(A[i],H):\n dp[h] = min(dp[h],dp[h-A[i]]+B[i])\n dp[H] = min(dp[H],min(dp[H-A[i]:H]+B[i]))\n ans = dp[-1]\n return ans\n\nH, N = map(int, input().split())\nA = np.zeros(N,np.int64)\nB = np.zeros(N,np.int64)\nfor i in range(N):\n A[i],B[i] = map(int, input().split())\nprint(main(H,N,A,B))']
['Wrong Answer', 'Accepted']
['s480359725', 's370557771']
[3188.0, 106720.0]
[23.0, 524.0]
[468, 516]
p02787
u706929073
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.
['inf = 10 ** 18\nh, n = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(n)]\nmax_a = max(a for a, _ in ab)\ndp = [inf] * (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 ab)\nprint(dp[h:])\n', 'h, n = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(n)]\nmax_a = max(a for a, _ in ab)\ndp = [10 ** 18 for _ in range(h + max_a)]\ndp[0] = 0\nfor i in range(1, h + max_a):\n dp[i] = max(dp[i-a] + b for a, b in ab)\nprint(min(dp[h:]))', 'h, n = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(n)]\nmax_a = max(a for a, _ in ab)\ndp = [10 ** 18 for _ in range(h + max_a)]\n\ndp[0] = 0\nfor i in range(1, h + max_a):\n dp[i] = min(dp[i-a] + b for a, b in ab)\nprint(min(dp[h:]))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s269507676', 's690851823', 's190526310']
[4088.0, 3868.0, 3832.0]
[1771.0, 1759.0, 1787.0]
[258, 264, 266]
p02787
u760569096
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())\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+])', 'h,n= map(int, input().split())\np = [list(map(int, input().split())) for _ in range(n)] \ni = 10**4\ndp = [0]*(h+i)\nfor i in range(i,h+i+1):\n dp[i] = min(dp[i-a] + b for a,b in p)\nprint(dp[h])', 'h,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])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s417454146', 's490950515', 's585501890']
[8868.0, 9604.0, 9592.0]
[25.0, 1072.0, 1140.0]
[197, 190, 196]
p02787
u769383879
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 ai, bi = map(int,input().split())\n a.append(ai)\n b.append(bi)\n\ndp = [0]*10001\n\nfor i in range(10001):\n dp[i] = (dp[i-a]+b).min()\n\nprint(dp[h])\n', 'h, n = map(int,input().split())\na = []\nb = []\nfor i in range(n):\n ai, bi = map(int,input().split())\n a.append(ai)\n b.append(bi)\n\nm = 0\nminc = 10**9\nnewi = -1\noldi = -2\ncost = 0\nwhile not newi == oldi:\n oldi = newi\n for i in range(len(n)):\n cost = b[i]*int((h-1)/a[i]+1)\n if cost < minc:\n newi = i\n h -= a[newi]*int((h-1)/a[newi])\n m += b[newi]*int((h-1)/a[newi])\n if newi == oldi:\n m += b[newi]\n\nprint(m)\n', 'import numpy as np\n\nh, n = map(int,input().split())\na = np.zeros(n, dtype = int)\nb = np.zeros(n, dtype = int)\nfor i in range(n):\n a[i], b[i] = map(int,input().split())\n\ndp = np.zeros(10001, dtype = int)\n\nfor i in range(1,10001):\n dp[i] = (dp[i-a]+b).min()\n\nprint(dp[h])\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s594911115', 's759260254', 's220785440']
[3060.0, 3064.0, 12484.0]
[20.0, 21.0, 418.0]
[221, 461, 276]
p02787
u780475861
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\nimport sys\nread=sys.stdin.read\n\nh,n,*ab=map(int,read().split())\na=np.array(ab[::2])\nb=np.array(ab[1::2])\n\nmagic=np.zeros(h+1)\nfor i in range(1,1+h):\n magic[i]=np.min(dp[np.maximum(i-a, 0)]+b)\nprint(magic[h])', 'import numpy as np\nimport sys\nread=sys.stdin.read\n\nh,n,*ab=map(int,read().split())\na=np.array(ab[::2])\nb=np.array(ab[1::2])\n\nmagic=np.zeros(h+1,dtype=np.int64)\nfor i in range(1,1+h):\n magic[i]=np.min(magic[np.maximum(i-a, 0)]+b)\nprint(magic[h])']
['Runtime Error', 'Accepted']
['s868778627', 's854413857']
[12504.0, 12516.0]
[149.0, 432.0]
[227, 245]
p02787
u810356688
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\ndef input(): return sys.stdin.readline().rstrip()\nimport numpy as np\ndef main():\n h,n=map(int,input().split())\n lis=np.array([list(map(int,input().split())) for _ in range(n)])\n a_max=np.max(lis[:,0])\n dp=np.zeros(h+a_max+1,int)\n for i in range(1,h+1):\n dp[i+lis[:,0]]=np.min(dp[i+lis[:,0]],dp[i]+lis[:,1])\n print(dp[h])\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nimport numpy as np\ndef main():\n h,n=map(int,input().split())\n lis=np.array([list(map(int,input().split())) for _ in range(n)])\n a_max=np.max(lis[:,0])\n dp=np.zeros(h+a_max+1,int)\n for i in range(1,h+1):\n dp[i+lis[:,0]]=np.minimum(dp[i+lis[:,0]],dp[i]+lis[:,1])\n print(dp[h])\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nfrom collections import Counter\ndef main():\n n=int(input())\n A=list(map(int,input().split()))\n X,Y=[0]*n,[0]*n\n for i in range(n):\n X[i]=i+A[i]\n Y[i]=i-A[i]\n set_x=set(X)\n yc=Counter(Y)\n xc=Counter(X)\n ans=0\n for x in set_x:\n ans+=xc[x]*yc[x]\n print(ans)\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nimport numpy as np\ndef main():\n h,n=map(int,input().split())\n lis=np.array([list(map(int,input().split())) for _ in range(n)])\n a_max=np.max(lis[:,0])\n dp=np.full(h+a_max+1,10**10)\n dp[0]=0\n for l in lis:\n dp[i:i+l[0]+1]=np.minimum(dp[i:i+l[0]+1],dp[i]+l[1])\n print(dp)\n print(dp[h])\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nimport numpy as np\ndef main():\n h,n=map(int,input().split())\n lis=np.array([list(map(int,input().split())) for _ in range(n)])\n a_max=np.max(lis[:,0])\n dp=np.zeros(h+a_max+1,int)\n for i in range(a_max+1,a_max+h+1):\n dp[i]=np.min(dp[i-lis[:,0]]+lis[:,1])\n print(dp[a_max+h])\n\nif __name__=='__main__':\n main()"]
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s604056151', 's726311524', 's839192812', 's963554537', 's671677804']
[19596.0, 12624.0, 3316.0, 27528.0, 27448.0]
[268.0, 529.0, 21.0, 107.0, 211.0]
[393, 397, 403, 412, 396]
p02787
u825378567
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.
['INF=10**10\ndef main():\n H,N=map(int,input().split())\n AB=[]\n for i in range(N):\n AB.append(list(map(int,input().split())))\n dp=[INF]*(H+1)\n dp[0]=0\n for a,b in AB:\n for k in range(H+1):\n tmp=k-a\n if tmp<0:\n tmp=0\n need_magic=dp[tmp]+b\n if need_magic<dp[k]:\n dp[k]=need_magic\n print(dp[H+1])\nmain()\n ', 'INF=10**10\ndef main():\n H,N=map(int,input().split())\n AB=[]\n for i in range(N):\n AB.append(list(map(int,input().split())))\n dp=[INF]*(H+1)\n dp[0]=0\n for a,b in AB:\n for k in range(H+1):\n tmp=k-a\n if tmp<0:\n tmp=0\n need_magic=dp[tmp]+b\n if need_magic<dp[k]:\n dp[k]=need_magic\n print(dp[H])\nmain()\n \n']
['Runtime Error', 'Accepted']
['s753142252', 's745806353']
[3572.0, 3572.0]
[1870.0, 1887.0]
[351, 350]
p02787
u839188633
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 functools import lru_cache\nimport sys\n\nsys.setrecursionlimit(10 ** 8)\n\nH, N = map(int, input().split())\nAB = [tuple(map(int, input().split())) for _ in range(N)]\n\n\nAB.sort(key=lambda ab: (ab[1] / ab[0], ab[0]))\n\n\n@lru_cache(maxsize=None)\ndef dp(h):\n if h <= 0:\n return 0\n else:\n for a, b in AB:\n val = b + dp(h - a)\n if val < best:\n best = val\n else:\n \n break\n return best\n\n\nprint(dp(H))\n', 'from functools import lru_cache\nimport sys\n\nsys.setrecursionlimit(10 ** 8)\n\nH, N = map(int, input().split())\nAB = [tuple(map(int, input().split())) for _ in range(N)]\n\n\nAB.sort(key=lambda ab: (ab[1] / ab[0], ab[0]))\n\n\n@lru_cache(maxsize=None)\ndef dp(h):\n if h <= 0:\n return 0\n else:\n best = float("inf")\n for a, b in AB:\n val = b + dp(h - a)\n if val < best:\n best = val\n else:\n \n break\n return best\n\n\nprint(dp(H))\n']
['Runtime Error', 'Accepted']
['s050223141', 's971563732']
[31372.0, 30180.0]
[181.0, 76.0]
[657, 688]
p02787
u842964692
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\nH,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)\n\n\n\nDP=[math.inf]*(H+max(A)-1)\n\nfor Ai in A:\n DP[Ai-1]=Ai \n\nfor dpi in range(H+max(A)-1):\n kouho=[]\n for Ai,Bi in zip(A,B):\n kouho.append(DP[dpi])\n if dpi-Ai>=0:\n kouho.append(DP[dpi-Ai]+Bi)\n DP[dpi]=min(kouho)\n\n\nprint(min(DP[H-1:]))', '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)\n\nDP=[10**9]*(H+max(A)-1)\n\nfor Ai in zip(A,B):\n DP[Ai-1]=Bi\n\nfor dpi in range(H+max(A)-1):\n kouho=[]\n kouho.append(DP[dpi])\n for Ai,Bi in zip(A,B):\n if dpi-Ai>=0:\n kouho.append(DP[dpi-Ai]+Bi)\n DP[dpi]=min(kouho)\n\n\nprint(min(DP[H-1:]))', 'h,n=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(n)]\n\nmax_a=max(a for a,_ in ab)\ndp = [0] * (h+max_a)\n\nfor i in range(0,h+max_a):\n if i==0:\n d[i]=0\n else:\n dp[i]=min(dp[i-a]+b for a,b in ab)\nprint(min(dp[h:]))\n', 'h,n=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(n)]\n\nmax_a=max(a for a,_ in ab)\ndp = [0] * (h+max_a)\n\nfor i in range(0,h+max_a):\n if i==0:\n d[i]=0\n else:\n dp[i]=min(dp[i-a]+b for a,b in ab)\nprint(min(dp[h:])\n\n', '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)\n\nDP=[10**9]*(H+max(A)-1)\n\nfor Ai,Bi in zip(A,B):\n DP[Ai-1]=Bi\n\nfor dpi in range(H+max(A)-1):\n \n \n kouho=DP[dpi]\n for Ai,Bi in zip(A,B):\n if dpi-Ai>=0:\n if kouho<DP[dpi-Ai]+Bi\n \n DP[dpi]=kouho\n\n\nprint(min(DP[H-1:]))', 'h,n=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(n)]\n\nmax_a=max(a for a,_ in ab)\n\nfor i in range(0,h+max_a):\n if i==0:\n d[i]=0\n else:\n dp[i]=min(dp[i-a]+b for a,b in ab)\nprint(min(dp[h:])\n', '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)\n\nDP=[10**9]*(H+max(A)-1)\n\nfor Ai in A:\n DP[Ai-1]=Ai \n\nfor dpi in range(H+max(A)-1):\n kouho=[]\n kouho.append(DP[dpi])\n for Ai,Bi in zip(A,B):\n if dpi-Ai>=0:\n kouho.append(DP[dpi-Ai]+Bi)\n DP[dpi]=min(kouho)\n\n\nprint(min(DP[H-1:]))', 'h,n=map(int,input().split())\nab=[list(int,input().split()) for _ in range(n)]\n\nmax_a=max(a for a,_ in ab)\n\nfor i in range(0,h+max_a):\n if i==0:\n d[i]=0\n else:\n dp[i]=min(dp[i-a]+b for a,b in ab)\nprint(min(dp[h:])\n', '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)\n\nDP=[10**9]*(H+max(A)-1)\n\nfor Ai in A:\n DP[Ai-1]=Ai \n\nfor dpi in range(H+max(A)-1):\n kouho=[]\n for Ai,Bi in zip(A,B):\n kouho.append(DP[dpi])\n if dpi-Ai>=0:\n kouho.append(DP[dpi-Ai]+Bi)\n DP[dpi]=min(kouho)\n\n\nprint(min(DP[H-1:]))', '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)\n\nDP=[10**9]*(H+max(A)-1)\n\nfor Ai,Bi in zip(A,B):\n DP[Ai-1]=Bi\n\nfor dpi in range(H+max(A)-1):\n \n \n kouho=DP[dpi]\n for Ai,Bi in zip(A,B):\n if dpi-Ai>=0:\n if kouho<DP[dpi-Ai]+Bi:\n \n DP[dpi]=kouho\n\n\nprint(min(DP[H-1:]))', 'h,n=map(int,input().split())\nab=[list(map(int,input().split())) for _ in range(n)]\n\nmax_a=max(a for a,_ in ab)\ndp = [0] * (h+max_a)\n\nfor i in range(0,h+max_a):\n if i==0:\n dp[i]=0\n else:\n dp[i]=min(dp[i-a]+b for a,b in ab)\nprint(min(dp[h:]))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s133526354', 's330185233', 's376021668', 's394498910', 's399418255', 's439704509', 's658984558', 's854274852', 's960819350', 's962662546', 's891391008']
[3064.0, 3188.0, 3316.0, 3060.0, 3064.0, 2940.0, 3356.0, 2940.0, 3364.0, 3064.0, 3668.0]
[20.0, 20.0, 20.0, 17.0, 17.0, 18.0, 2104.0, 17.0, 2104.0, 17.0, 1613.0]
[532, 460, 260, 260, 514, 238, 454, 233, 458, 515, 260]
p02787
u852613820
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\ninput = sys.stdin.readlin\nINF = float(\'INF\')\n\n\ndef main():\n H, N = map(int, input().split())\n skills = [None] * N\n max_a = 0\n for i in range(N):\n a, b = map(int, input().split())\n if a > max_a:\n max_a = a\n skills[i] = (a, b)\n\n \n \n dp = [INF] * (H + max_a + 1111\n dp[0]=0\n\n\n \n for i in range(H):\n \n if dp[i] == INF:\n continue\n\n \n for a, b in skills:\n \n mp=dp[i] + b\n \n \n if mp < dp[i + a]:\n dp[i + a]=mp\n\n \n print(min(dp[H:]))\n\n\n if __name__ == "__main__":\n main()\n', 'import sys\ninput = sys.stdin.readline\nINF = float(\'INF\')\n\n\ndef main():\n H, N = map(int, input().split())\n skills = [None] * N\n max_a = 0\n for i in range(N):\n a, b = map(int, input().split())\n if a > max_a:\n max_a = a\n skills[i] = (a, b)\n\n \n \n dp = [INF] * (H + max_a + 1)\n dp[0] = 0\n\n \n for i in range(H):\n \n if dp[i] == INF:\n continue\n\n \n for a, b in skills:\n \n mp = dp[i] + b\n \n \n if mp < dp[i + a]:\n dp[i + a] = mp\n\n \n print(min(dp[H:]))\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s504962488', 's938685145']
[2940.0, 3544.0]
[17.0, 1776.0]
[1314, 1315]
p02787
u873616440
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())\nA = []\nB = []\nfor _ in range(N):\n ai, bi = map(int, input().split())\n A.append(ai)\n B.append(bi)\n\n# process\ndp = np.zeros(H+1, dtype=np.int64)\ndp[0] = 0\n\nfor i in range(1, H + 1):\n dp[i] = np.amin(dp[np.maximum(i - A, 0)] + B)\n\n# output\nprint(dp[H])\n', 'import numpy as np\nH, N = map(int, input().split())\nA = []\nB = []\nfor _ in range(N):\n ai, bi = map(int, input().split())\n A.append(ai)\n B.append(bi)\n\nA = np.array(A)\nB = np.array(B)\n# process\ndp = np.zeros(H+1, dtype=np.int64)\ndp[0] = 0\n\nfor i in range(1, H + 1):\n dp[i] = np.amin(dp[np.maximum(i - A, 0)] + B)\n\n# output\nprint(dp[H])\n\n']
['Runtime Error', 'Accepted']
['s206900234', 's449626877']
[12652.0, 12508.0]
[152.0, 430.0]
[308, 341]
p02787
u887152994
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\nimport numpy as np\nH,N=map(int,input().split)\nA=[]\nB=[]\nfor i in range(N):\n n,a=input().split()\n A.append(int(n))\n B.append(int(a))\nC=[]\nfor i in range(N):\n C.append(A[i]/B[i])\nsub=0\nfor i in range(N):\n if C[i]>=C[sub]:\n sub=i\nsub2=math.ceil(H/A[sub])\nsub3=sub2*B[sub]\nfor ia in range(H,sub2):\n t = ia\n M = len(A) - 1\n elm = []\n for i, step in enumerate(A):\n temp = [1] * (M - i)\n elm.append(np.arange(0, t+1, step).reshape(-1, *temp))\n res = 0\n for x in elm:\n res = res + x\n sub4=0\n for x in np.argwhere(res == t):\n for ib in range(N):\n sub4+=B[ib]*x[ib]\n if sub4<=sub3:\n sub3=sub4\nprint(sub3)', 'H,N=map(int,input().split())\nA=[]\nB=[]\nfor i in range(N):\n n,a=input().split()\n A.append(int(n))\n B.append(int(a))\ndef f(x):\n if x<=0:\n return 0\n else:\n mini=g(x-A[0])+B[0]\n for i in range (1,N):\n sub=g(x-A[i])+B[i]\n if sub<mini:\n mini=sub\n return mini\ndef g(x):\n if x<0:\n return 0\n else:\n return g_list[x]\ng_list=[]\ng_list.append(0)\nfor i in range(1,H+1):\n g_list.append(f(i))\nprint(g_list[-1])']
['Runtime Error', 'Accepted']
['s024873285', 's682471215']
[9008.0, 9392.0]
[27.0, 1793.0]
[647, 498]
p02787
u919730120
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())\n2.ab = [list(map(int, input().split())) for _ in range(n)]\n3.dp =[0]*(h+max(ab[0:n][0]))\n4.for i in range(1, h+1):\n5. dp[i] = min(dp[i-a]+b for a,b in ab)\n6.print(dp[h])', "def main():\n h, n = map(int, input().split())\n ab = [list(map(int, input().split())) for _ in range(n)]\n dp =[0]*(h+max(a for a,b in ab))\n for i in range(1, h+1):\n dp[i] = min(dp[i-a]+b for a,b in ab)\n print(dp[h])\n \nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Accepted']
['s422163872', 's201298056']
[2940.0, 3648.0]
[17.0, 1343.0]
[203, 281]
p02787
u933722792
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 main():\n h, n = map(int, input().split())\n ab = [list(map(int, input().split())) for _ in range(n)]\n\n dp = [0] + [0] * h\n for i in range(1, h + 1):\n dp[i] = min(dp[i - a] + b for a, b in ab)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n h, n = map(int, input().split())\n ab = [list(map(int, input().split())) for _ in range(n)]\n\n amax = max(a for a, b in ab)\n dp = [0] + [0] * (h + amax)\n for i in range(1, h + 1):\n dp[i] = min(dp[i - a] + b for a, b in ab)\n print(dp[h])\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s867045745', 's579357936']
[9472.0, 9572.0]
[1035.0, 1076.0]
[254, 313]
p02787
u941438707
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),*c=[[*map(int,i.split())]for i in open(0)]\ndp=[10**9]*(2*10**4+1)\nc.sort()\ndp[0]=0\nfor i in range(h):\n if dp[i]==10**9:break\n for a,b in c:\n if i+a<=2*10**4:\n dp[i+a]=min(dp[i+a],dp[i]+b)\n else:break \nprint(min(dp[h:]))', '(h,n),*c=[[*map(int,i.split())]for i in open(0)]\nd=[0]*20002\nfor i in range(h):d[i]=min(d[i-a]+b for a,b in c)\nprint(d[h-1])']
['Wrong Answer', 'Accepted']
['s708924607', 's140009111']
[9564.0, 9504.0]
[2205.0, 1059.0]
[259, 124]
p02787
u961683878
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\nimport numpy as np\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(500000)\n\nH, N = map(int, readline().split())\nm = map(int, read().split())\nAB = np.array(zip(m, m))\n\nINF = 10**18\n\ndp = [INF] * (H + 1)\ndp[0] = 0\nfor a, b in AB:\n for n in range(H + 1):\n k = max(0, n - a)\n acc = dp[k] + b\n if acc < dp[n]:\n dp[n] = acc\n\nprint(dp[H])', 'import sys\nimport numpy as np\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(500000)\n\nH, N = map(int, readline().split())\nAB = np.array([list(map(int,\n readline().split())) for _ in range(N)],\n dtype=np.int64)\n\nA = AB[:, 0]\nB = AB[:, 1]\n\ndp = np.zeros(H + 1, dtype=np.int64)\nfor n in range(1, H + 1):\n dp[n] = np.amin(dp[np.maximum(n - A, 0)] + B)\n\nprint(dp[H])']
['Runtime Error', 'Accepted']
['s605954612', 's809017102']
[12504.0, 14540.0]
[154.0, 443.0]
[456, 480]
p02787
u972652761
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.
['\nH,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', '\nH,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']
['Runtime Error', 'Accepted']
['s761312342', 's355236569']
[3648.0, 3776.0]
[1705.0, 1656.0]
[333, 333]
p02787
u997641430
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.
['inf = 10**10\nH, N = map(int, input().split())\nA = []\nB = []\nfor n in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\ndp = [inf] * (H + 10 ** 4)\nfor n in range(N):\n for h in range(H):\n if dp[h] == inf:\n continue\n dp[h + A[n]] = min(dp[h + A[n]], dp[h] + B[n])\nprint(min(dp[H:]))\n', 'def main():\n inf = 10**9\n H, N = map(int, input().split())\n AB = []\n for n in range(N):\n a, b = map(int, input().split())\n AB.append((a, b))\n AB.sort(reverse=True, key=lambda x: x[0])\n dp = [inf] * (H + 10 ** 4)\n dp[0] = 0\n for a, b in AB:\n for h in range(H):\n if dp[h] != inf:\n tmp = dp[h] + b\n if tmp < dp[h + a]:\n dp[h + a] = tmp\n print(min(dp[H:]))\n\n\nmain()\n']
['Wrong Answer', 'Accepted']
['s342672299', 's526102164']
[3316.0, 3692.0]
[1141.0, 1886.0]
[337, 470]
p02788
u054514819
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['import numpy as np\nimport math\nimport bisect\n\nN, D, A = map(int, input().split())\nxh = np.array(sorted([list(map(int, input().split())) for _ in range(N)]))\ndamage = np.array([0]*N)\nb = 0\nfor i in range(N):\n if damage[i]>=xh[i, 1]:\n continue\n x, h = xh[i]\n r = min(x+2*D, xh[-1, 0])\n times = math.ceil(h/A)\n damage[:bisect.bisect_right(xh[:, 0], r, i, N)] += times*A\n b += times\nprint(b)', 'import bisect\n\nN, D, A = map(int, input().split())\nxh = sorted([list(map(int, input().split())) for _ in range(N)])\nds = [0]*N\nb = 0\nXs = [x for x, h in xh]\nfor i in range(N):\n x, h = xh[i]\n if ds[i]>=h:\n continue\n r = min(x+2*D, xh[-1][0])\n times = h//A if h%A==0 else h//A+1\n for j in range(i, (bisect.bisect_right(Xs, r))):\n \tds[j] += times*A\n print(ds)\n b += times\nprint(b)', 'import bisect\n\nN, D, A = map(int, input().split())\nxh = sorted([list(map(int, input().split())) for _ in range(N)])\nds = [0]*N\nb = 0\nXs = [x for x, h in xh]\nfor i in range(N):\n x, h = xh[i]\n if ds[i]>=h:\n continue\n r = min(x+2*D, xh[-1][0])\n times = h//A if h%A==0 else h//A+1\n for j in range(x, (bisect.bisect_right(Xs, r))):\n \tds[j] += times*A\n b += times\nprint(b)', 'import numpy as np\nimport math\nimport bisect\n\nN, D, A = map(int, input().split())\nxh = np.array(sorted([list(map(int, input().split())) for _ in range(N)]), dtype=int32)\nb = 0\nfor _ in range(N):\n if len(xh)==0:\n break\n x, h = xh[0]\n r = min(x+2*D, xh[-1, 0])\n times = h//A if h%A==0 else h//A+1\n xh[:bisect.bisect_right(xh[:, 0], r)] -= times*A\n xh = xh[xh[:, 1]>0]\n b += times\nprint(b)', 'import bisect\n\nN, D, A = map(int, input().split())\nxh = sorted([list(map(int, input().split())) for _ in range(N)])\nds = [0]*N\nb = 0\nXs = [x for x, h in xh]\nfor i in range(N):\n x, h = xh[i]\n if ds[i]>=h:\n continue\n r = min(x+2*D, xh[-1][0])\n times = h//A if h%A==0 else h//A+1\n for j in range(i, (bisect.bisect_right(Xs, r))):\n \tds[j] += times*A\n b += times\nprint(b)', "from bisect import bisect_right\n\nN, D, A = map(int, input().split())\nxh = sorted([list(map(int, input().split())) for _ in range(N)])\nds = [0]*(N+1)\nb = 0\n# Xs = [x for x, h in xh]\nfor i in range(N):\n x, h = xh[i]\n if ds[i]>=h:\n continue\n times = h//A if h%A==0 else h//A+1\n for j in range(i, (bisect_right(xh, [x+2*D, float('inf')]))):\n \tds[j] += times*A\n b += times\nprint(b)", 'import bisect\n\nN, D, A = map(int, input().split())\nxh = sorted([list(map(int, input().split())) for _ in range(N)])\nds = [0]*(N+1)\nb = 0\nXs = [x for x, h in xh]\nfor i in range(N):\n x, h = xh[i]\n if ds[i]>=h:\n continue\n r = min(x+2*D, xh[-1][0])\n times = h//A if h%A==0 else h//A+1\n for j in range(i, (bisect.bisect_right(Xs, r))):\n \tds[j] += times*A\n b += times\nprint(b)', "from bisect import bisect_right\n\nN, D, A = map(int, input().split())\nxh = sorted([list(map(int, input().split())) for _ in range(N)])\nds = [0]*(N+2)\nb = 0\nfor i, (x, h) in enumerate(xh, 1):\n ds[i] += ds[i-1]\n d = ds[i]\n if d>=h:\n continue\n h -= d\n times = h//A if h%A==0 else h//A+1\n ds[i] += times*A\n ds[bisect_right(xh, [x+2*D, float('inf')])+1] -= times*A\n b += times\nprint(b)"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s048974019', 's263499863', 's397047060', 's516914050', 's683404967', 's698079004', 's967145786', 's130477561']
[64068.0, 168084.0, 63320.0, 63184.0, 61308.0, 59736.0, 61308.0, 59944.0]
[2111.0, 2108.0, 1735.0, 1084.0, 1513.0, 1611.0, 1521.0, 1609.0]
[396, 388, 376, 396, 376, 385, 380, 390]
p02788
u078932560
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from math import ceil\nimport bisect\n\nN, D, A = map(int, input().split())\nMonsters = sorted([list(map(int, input().split())) for i in range(N)])\nX = [x for x, h in Monsters]\nH = [ceil(h / A) for x, h in Monsters]\n\nmin_n = 0\n\nfor i in range(N):\n if H[i] <= 0:\n continue\n i_2Di = bisect.bisect_left(X, X[i]+2*D)\n H[i:i_2Di] -= A * ni\n min_n += ni\n \nprint(min_n)', 'from math import ceil\nimport bisect\n\nN, D, A = map(int, input().split())\nMonsters = sorted([list(map(int, input().split())) for i in range(N)])\nX = [x for x, h in Monsters]\nH = [ceil(h / A) for x, h in Monsters]\n\nmin_n = 0\n\nfor i in range(N):\n if H[i] <= 0:\n continue\n \n for j in range(i+1,N):\n if X[j] - X[i] > 2*D:\n i_2Di = j\n break\n H[i:i_2Di] -= A * ni\n min_n += ni\n \nprint(min_n)', 'from math import ceil\nfrom collections import deque\nN, D, A = map(int, input().split())\nMonsters = sorted([list(map(int, input().split())) for i in range(N)])\nMonsters = [[x, ceil(h / A)] for x, h in Monsters]\n\n\nacc_damage = 0\nque = deque([])\n\nans = 0\nfor x, h in Monsters:\n \n while que and x > que[0][0]:\n limit, damage = que.popleft()\n acc_damage -= damage\n\n need = max(0, h - acc_damage)\n ans += need\n acc_damage += need\n\n if need:\n que.append([x + 2 * D, need])\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s669716960', 's680362396', 's355608680']
[62868.0, 62100.0, 73212.0]
[1181.0, 1247.0, 1611.0]
[366, 446, 560]
p02788
u111473084
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['n, d, a = map(int, input().split())\nxh = [list(map(int, input().split())) for _ in range(n)]\nxh.sort()\n\ntarget = 0\ncnt = 0\nwhile target < n:\n x, h = xh[target]\n atk_end = x + d + d\n atk_cnt = (h + a - 1) // a\n cnt += atk_cnt\n for i in range(target, n):\n if xh[i][0] > atk_end:\n break\n xh[i][1] -= a * atk_cnt\n if xh[i][1] < 1 and i == target+1:\n target += 1\n # while xh[target][1] < 1:\n # target += 1\n # if target >= n:\n # break\n\nprint(cnt)', 'n, d, a = map(int, input().split())\nxh = [list(map(int, input().split())) for _ in range(n)]\nxh.sort()\n\ntarget = 0\ncnt = 0\nwhile xh[n-1][1] > 0:\n x, h = xh[target]\n atk_end = x + d + d\n atk_cnt = (h + a - 1) // a\n cnt += atk_cnt\n for i in range(target, n):\n if xh[i][0] > atk_end:\n break\n xh[i][1] -= a * atk_cnt\n if xh[i][1] < 1 and i == target+1:\n target += 1\n\nprint(cnt)', 'import math\nfrom collections import deque\n\nn, d, a = map(int, input().split())\nxh = [list(map(int, input().split())) for _ in range(n)]\nxh.sort(key=lambda x:x[0])\nxh = deque(xh)\n\nxh_field = deque()\n\ncnt = 0\nnow_damage = 0\nwhile xh:\n pos, hp = xh.popleft()\n if xh_field:\n while (xh_field and xh_field[0][0] < pos) :\n now_damage -= a * xh_field[0][1]\n xh_field.popleft() \n if hp <= now_damage:\n pass\n elif hp > now_damage:\n atk_cnt = math.ceil((hp - now_damage) / a)\n cnt += atk_cnt\n now_damage += atk_cnt * a\n xh_field.append((2*d + pos, atk_cnt)) \nprint(cnt)\n']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s495384424', 's629724183', 's419375995']
[52644.0, 52644.0, 56124.0]
[2107.0, 2110.0, 1172.0]
[526, 431, 642]
p02788
u113971909
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from bisect import bisect_left, bisect_right\nimport sys\nimport numpy as np\ninput = sys.stdin.readline\nN,D,A=map(int, input().split())\nmg = [None]*N\nX = [None]*N\nH = [None]*N\nXD = [None]*N\nfor i in range(N):\n mg[i]=list(map(int, input().split()))\nmg.sort(key=lambda x:x[0])\nmg = (np.array(mg)).T\nX = mg[0]\nH = mg[1]\nfor i in range(N):\n XD[i] = bisect_right(X[i+1:],X[i]+2*D) + i\nXD = np.array(XD)\ni = 0\nans = 0\nwhile i<N:\n if H[i]>0:\n k = (H[i]+A-1)//A\n ans +=k\n H[i:XD[i]]=np.maximum(0,H[i:XD[i]]-k*A)\n i+=1\nprint(ans)', '#!/usr/bin python3\n# -*- coding: utf-8 -*-\n\nfrom bisect import bisect_left, bisect_right\n\nn, d, a = map(int, input().split())\nx = []\nxh = dict()\nfor _ in range(n):\n xi, hi = map(int, input().split())\n x.append(xi)\n xh[xi] = hi\nx.sort()\n\nl = 0\nret = 0\nai = [0] * (n+1)\nanow = 0\nwhile l < n:\n xl = x[l]\n hl = xh[xl]\n anow += ai[l]\n hl -= a * anow\n if hl > 0:\n r = bisect_right(x, xl+2*d)\n k = (hl+(a-1))//a\n ret += k\n anow += k\n ai[r] -= k\n l += 1\nprint(ret)\n']
['Wrong Answer', 'Accepted']
['s933015985', 's181133891']
[68924.0, 41220.0]
[2111.0, 734.0]
[531, 519]
p02788
u135346354
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['import sys\ninput = sys.stdin.readline\n\nN, D, A = map(int, input().split())\nS = [0]*N\nfor i in range(N):\n x, h = map(int, input().split())\n S[i] = [x, -(-h//A)]\n\nS.sort()\nprint()\ncnt = 0\n\nfor i in range(N):\n if S[i][1] <= 0:\n continue\n cnt += S[i][1]\n dmg = S[i][1]\n max_X = S[i][0] + D*2\n for j in range(i+1, N):\n if S[j][0] > max_X:\n break\n S[j][1] -= dmg\n\nprint(cnt)\n', 'import sys\ninput = sys.stdin.readline\n\nN, D, A = map(int, input().split())\nS = [0]*N\nfor i in range(N):\n x, h = map(int, input().split())\n if h % A == 0:\n h //= A\n else:\n h = h//A + 1\n S[i] = [x, h]\n\nS.sort()\nprint()\ncnt = 0\n\nfor i in range(N):\n if S[i][1] <= 0:\n continue\n cnt += S[i][1]\n dmg = S[i][1]\n max_X = S[i][0] + D*2\n for j in range(i+1, N):\n if S[j][0] > max_X:\n break\n S[j][1] -= dmg\n\nprint(cnt)\n', 'from collections import deque\nimport math\n\nimport sys\ninput = sys.stdin.readline\n\nN, D, A = map(int, input().split())\nS = [0]*N\natack = deque()\nfor i in range(N):\n x, h = map(int, input().split())\n S[i] = [x, h]\n\nS.sort()\ncnt = 0\ndmg = 0\nfor i in range(N):\n while atack:\n if atack[0][0] < S[i][0]:\n x, d = atack.popleft()\n dmg -= d\n else:\n break\n\n if S[i][1] <= dmg:\n continue\n bomb = math.ceil((S[i][1]-dmg)/A)\n atack.append([S[i][0]+2*D, A*bomb])\n cnt += bomb\n dmg += A*bomb\n\nprint(cnt)\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s072398209', 's505847341', 's786367409']
[37104.0, 38184.0, 53980.0]
[2110.0, 2106.0, 962.0]
[422, 481, 567]
p02788
u139112865
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['#153_F\nfrom bisect import bisect_right\nn, d, a = map(int, input().split())\nmons = sorted([tuple(map(int, input().split())) for _ in range(n)])\nx = [mons[i][0] for i in range(n)]\nh = [mons[i][1] for i in range(n)]\ndamage = [0 for _ in range(n+1)]\ncnt = 0\nfor i in range(n):\n if i > 0:\n damage[i] += damage[i-1]\n if h[i] <= damage[i] - damage[i-1]:\n continue\n \n cur_cnt = -(-(h[i]-damage[i]) // a)\n cnt += cur_cnt\n damage[i] += cur_cnt * a\n idx = bisect_right(x, x[i] + 2 * d)\n damage[idx] -= cur_cnt * a\n \nprint(cnt)\nprint(damage)', '#153_F\nfrom bisect import bisect_right\nn, d, a = map(int, input().split())\nmons = sorted([tuple(map(int, input().split())) for _ in range(n)])\nx = [mons[i][0] for i in range(n)]\nh = [mons[i][1] for i in range(n)]\ndamage = [0 for _ in range(n+1)]\ncnt = 0\nfor i in range(n):\n if i > 0:\n damage[i] += damage[i-1]\n if h[i] <= damage[i]:\n continue\n \n cur_cnt = -(-(h[i]-damage[i]) // a)\n cnt += cur_cnt\n damage[i] += cur_cnt * a\n idx = bisect_right(x, x[i] + 2 * d)\n damage[idx] -= cur_cnt * a\n \nprint(cnt)']
['Wrong Answer', 'Accepted']
['s920060741', 's585353946']
[49196.0, 41132.0]
[1309.0, 1304.0]
[578, 550]
p02788
u169350228
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['import math\nn, d, a = map(int,input().split())\ne = [[] for i in range(n)]\nfor i in range(n):\n x, h = map(int,input().split())\n e[i] = [x,h]\nnum = 0\n\ne.sort()\nsd = [0 for i in range(n)]\nl = [i for i in range(n)]\nfor i in range(n):\n for j in range(l[i-1],i):\n if e[i][0]-e[j][0] <= 2*d:\n l[i] = j\n break\n\nfor i in range(n):\n res = x[i][1] - sd[i-1] + sd[l[i]-1]\n if res < 0:\n sd[i] = sd[i-1]\n else:\n k = math.ceil(res/a)\n sd[i] = sd[i-1]+k*a\n num += k\n \nprint(num)\n', 'import math\nn, d, a = map(int,input().split())\ne = [[] for i in range(n)]\nfor i in range(n):\n x, h = map(int,input().split())\n e[i] = [x,h]\nnum = 0\n\ne.sort()\nsd = [0 for i in range(n)]\nl = [i for i in range(n)]\nfor i in range(n):\n for j in range(l[i-1],i):\n if e[i][0]-e[j][0] <= 2*d:\n l[i] = j\n break\n\nfor i in range(n):\n res = e[i][1] - sd[i-1] + sd[l[i]-1]\n if res < 0:\n sd[i] = sd[i-1]\n else:\n k = math.ceil(res/a)\n sd[i] = sd[i-1]+k*a\n num += k\n\nprint(num)\n']
['Runtime Error', 'Accepted']
['s517761374', 's412740167']
[46420.0, 54356.0]
[1253.0, 1469.0]
[545, 537]
p02788
u173148629
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['N,D,A=map(int,input().split())\nfrom heapq import heappop,heappush,heapify\nB=[]\nfor _ in range(N):\n x,h=map(int,input().split())\n B.append((x,h))\nheapify(B)\n\ndic={}\n\nans=0\natk_cnt=0\nwhile B:\n x,h=heappop(B)\n if h==-1:\n atk_cnt-=dic[x-1]\n continue\n if h<=A*atk_cnt:\n continue\n sup=x+2*D\n bomb=(h-1)//A+1\n ans+=bomb\n dic[sup]=bomb\n atk_cnt+=bomb\n heappush(B,(sup+1,-1))\n \nprint(ans)\n', 'N,D,A=map(int,input().split())\nfrom heapq import heappop,heappush,heapify\nB=[]\nfor _ in range(N):\n x,h=map(int,input().split())\n B.append((x,h))\nheapify(B)\n\ndic={}\n\nans=0\natk_cnt=0\nwhile B:\n x,h=heappop(B)\n if h==-1:\n atk_cnt-=dic[x-1]\n continue\n if h<=A*atk_cnt:\n continue\n h-=A*atk_cnt\n sup=x+2*D\n bomb=(h-1)//A+1\n ans+=bomb\n dic[sup]=bomb\n atk_cnt+=bomb\n heappush(B,(sup+1,-1))\n \n \nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s249432073', 's715240800']
[47316.0, 52060.0]
[1620.0, 1233.0]
[437, 459]
p02788
u179169725
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
["\n\n\n\ndef _gidx(l, r, treesize):\n \n L, R = l + treesize, r + treesize\n lm = (L // (L & -L)) >> 1 \n rm = (R // (R & -R)) >> 1\n while L < R:\n if R <= rm:\n yield R\n if L <= lm:\n yield L\n L >>= 1\n R >>= 1\n while L: \n yield L\n L >>= 1\n\n\nimport operator\n\n\nclass LazySegmentTree: \n def __init__(self, ls: list, segfunc=operator.add, identity_element=0, lazy_ide=0):\n \n self.ide = identity_element\n self.lide = lazy_ide \n self.func = segfunc\n n = len(ls)\n self.num = 2 ** (n - 1).bit_length() \n self.tree = [self.ide] * (2 * self.num) \n self.lazy = [self.lide] * (2 * self.num) \n for i, l in enumerate(ls): \n self.tree[i + self.num - 1] = l\n for i in range(self.num - 2, -1, -1): \n self.tree[i] = segfunc(self.tree[2 * i + 1], self.tree[2 * i + 2])\n\n def _lazyprop(self, *ids):\n \n for i in reversed(ids):\n i -= 1 # to 0basedindex\n v = self.lazy[i]\n if v == self.lide:\n continue\n #########################################################\n \n self.tree[2 * i + 1] += v >> 1 \n self.tree[2 * i + 2] += v >> 1\n self.lazy[2 * i + 1] += v >> 1\n self.lazy[2 * i + 2] += v >> 1\n #########################################################\n\n self.lazy[i] = self.lide を空に戻す\n\n def update(self, l, r, x):\n \n \n ids = tuple(_gidx(l, r, self.num))\n #########################################################\n \n \n #########################################################\n \n if r <= l:\n return ValueError('invalid index (l,rがありえないよ)')\n l += self.num\n r += self.num\n while l < r:\n #########################################################\n \n if r & 1:\n r -= 1\n self.tree[r - 1] += x\n self.lazy[r - 1] += x\n if l & 1:\n self.tree[l - 1] += x\n self.lazy[l - 1] += x\n l += 1\n #########################################################\n x <<= 1 \n l >>= 1\n r >>= 1\n \n for i in ids:\n i -= 1 # to 0based\n #########################################################\n \n \n self.tree[i] = self.func(\n self.tree[2 * i + 1], self.tree[2 * i + 2]) + self.lazy[i]\n #########################################################\n\n def query(self, l, r):\n \n if r <= l:\n return ValueError('invalid index (l,rがありえないよ)')\n \n self._lazyprop(*_gidx(l, r, self.num))\n \n l += self.num\n r += self.num\n res = self.ide\n while l < r: \n if r & 1:\n r -= 1\n res = self.func(res, self.tree[r - 1])\n if l & 1:\n res = self.func(res, self.tree[l - 1])\n l += 1\n l >>= 1\n r >>= 1\n return res\n\n\nimport sys\nread = sys.stdin.readline\n\n\ndef read_ints():\n return list(map(int, read().split()))\n\n\ndef read_tuple(H):\n '''\n H is number of rows\n '''\n ret = []\n for _ in range(H):\n ret.append(tuple(map(int, read().split())))\n return ret\n\n\ndef read_col(H, n_cols):\n \n ret = [[] for _ in range(n_cols)]\n for _ in range(H):\n tmp = list(map(int, read().split()))\n for col in range(n_cols):\n ret[col].append(tmp[col])\n return ret\n\n\n\nfrom collections import defaultdict, Counter, deque\nfrom operator import itemgetter\nfrom itertools import product, permutations, combinations\nfrom fractions import gcd\nfrom bisect import bisect_left, bisect_right, insort_left, insort_right\n\n\nN, D, A = read_ints()\nXH = read_tuple(N)\n\nXH.sort()\n\nX = []\nH_cnt = []\nfor x, h in XH:\n H_cnt.append((h - 1) // A + 1)\n X.append(x)\n\nseg = LazySegmentTree(H_cnt)\n\nans = 0\nfor i in range(N):\n atk = seg.query(i, i + 1) \n if atk <= 0:\n continue\n ans += atk\n \n seg.update(i, bisect_left(X, X[i] + 2 * D + 1, lo=i), -atk)\n\nprint(ans)\n", "\n\n\n\ndef _gidx(l, r, treesize):\n \n L, R = l + treesize, r + treesize\n lm = (L // (L & -L)) >> 1 \n rm = (R // (R & -R)) >> 1\n while L < R:\n if R <= rm:\n yield R\n if L <= lm:\n yield L\n L >>= 1\n R >>= 1\n while L: \n yield L\n L >>= 1\n\n\nimport operator\n\n\nclass LazySegmentTree: \n def __init__(self, ls: list, segfunc=operator.add, identity_element=0, lazy_ide=0):\n \n self.ide = identity_element\n self.lide = lazy_ide \n self.func = segfunc\n n = len(ls)\n self.num = 2 ** (n - 1).bit_length() \n self.tree = [self.ide] * (2 * self.num) \n self.lazy = [self.lide] * (2 * self.num) \n for i, l in enumerate(ls): \n self.tree[i + self.num - 1] = l\n for i in range(self.num - 2, -1, -1): \n self.tree[i] = segfunc(self.tree[2 * i + 1], self.tree[2 * i + 2])\n\n def _lazyprop(self, *ids):\n \n for i in reversed(ids):\n i -= 1 # to 0basedindex\n v = self.lazy[i]\n if v == self.lide:\n continue\n #########################################################\n \n self.tree[2 * i + 1] += v >> 1 \n self.tree[2 * i + 2] += v >> 1\n self.lazy[2 * i + 1] += v >> 1\n self.lazy[2 * i + 2] += v >> 1\n #########################################################\n\n self.lazy[i] = self.lide を空に戻す\n\n def update(self, l, r, x):\n \n \n ids = tuple(_gidx(l, r, self.num))\n #########################################################\n \n \n #########################################################\n \n if r <= l:\n return ValueError('invalid index (l,rがありえないよ)')\n l += self.num\n r += self.num\n while l < r:\n #########################################################\n \n if r & 1:\n r -= 1\n self.tree[r - 1] += x\n self.lazy[r - 1] += x\n if l & 1:\n self.tree[l - 1] += x\n self.lazy[l - 1] += x\n l += 1\n #########################################################\n x <<= 1 \n l >>= 1\n r >>= 1\n \n for i in ids:\n i -= 1 # to 0based\n #########################################################\n \n \n self.tree[i] = self.func(\n self.tree[2 * i + 1], self.tree[2 * i + 2]) + self.lazy[i]\n #########################################################\n\n def query(self, l, r):\n \n if r <= l:\n return ValueError('invalid index (l,rがありえないよ)')\n \n self._lazyprop(*_gidx(l, r, self.num))\n \n l += self.num\n r += self.num\n res = self.ide\n while l < r: \n if r & 1:\n r -= 1\n res = self.func(res, self.tree[r - 1])\n if l & 1:\n res = self.func(res, self.tree[l - 1])\n l += 1\n l >>= 1\n r >>= 1\n return res\n\n\nimport sys\nread = sys.stdin.readline\n\n\ndef read_ints():\n return list(map(int, read().split()))\n\n\ndef read_tuple(H):\n '''\n H is number of rows\n '''\n ret = []\n for _ in range(H):\n ret.append(tuple(map(int, read().split())))\n return ret\n\n\ndef read_col(H, n_cols):\n \n ret = [[] for _ in range(n_cols)]\n for _ in range(H):\n tmp = list(map(int, read().split()))\n for col in range(n_cols):\n ret[col].append(tmp[col])\n return ret\n\n\n\nfrom bisect import bisect_left, bisect_right\n\n\nN, D, A = read_ints()\nXH = read_tuple(N)\n\nXH.sort()\n\nX = []\nH_cnt = []\nfor x, h in XH:\n H_cnt.append((h - 1) // A + 1)\n X.append(x)\n\nseg = LazySegmentTree(H_cnt)\n\nans = 0\nfor i in range(N):\n atk = seg.query(i, i + 1) \n if atk <= 0:\n continue\n ans += atk\n \n seg.update(i+1, bisect_left(X, X[i] + 2 * D + 1, lo=i), -atk)\n\nprint(ans)\n", "\n\n\n\ndef _gidx(l, r, treesize):\n \n L, R = l + treesize, r + treesize\n lm = (L // (L & -L)) >> 1 \n rm = (R // (R & -R)) >> 1\n while L < R:\n if R <= rm:\n yield R\n if L <= lm:\n yield L\n L >>= 1\n R >>= 1\n while L: \n yield L\n L >>= 1\n\n\nimport operator\n\n\nclass LazySegmentTree: \n def __init__(self, ls: list, segfunc=operator.add, identity_element=0, lazy_ide=0):\n \n self.ide = identity_element\n self.lide = lazy_ide \n self.func = segfunc\n n = len(ls)\n self.num = 2 ** (n - 1).bit_length() \n self.tree = [self.ide] * (2 * self.num) \n self.lazy = [self.lide] * (2 * self.num) \n for i, l in enumerate(ls): \n self.tree[i + self.num - 1] = l\n for i in range(self.num - 2, -1, -1): \n self.tree[i] = segfunc(self.tree[2 * i + 1], self.tree[2 * i + 2])\n\n def _lazyprop(self, *ids):\n \n for i in reversed(ids):\n i -= 1 # to 0basedindex\n v = self.lazy[i]\n if v == self.lide:\n continue\n #########################################################\n \n self.tree[2 * i + 1] += v \n self.tree[2 * i + 2] += v\n self.lazy[2 * i + 1] += v\n self.lazy[2 * i + 2] += v\n #########################################################\n\n self.lazy[i] = self.lide を空に戻す\n\n def update(self, l, r, x):\n \n \n ids = tuple(_gidx(l, r, self.num))\n #########################################################\n \n self._lazyprop(*ids)\n #########################################################\n \n if r <= l:\n return ValueError('invalid index (l,rがありえないよ)')\n l += self.num\n r += self.num\n while l < r:\n #########################################################\n \n if r & 1:\n r -= 1\n self.tree[r - 1] += x\n self.lazy[r - 1] += x\n if l & 1:\n self.tree[l - 1] += x\n self.lazy[l - 1] += x\n l += 1\n #########################################################\n l >>= 1\n r >>= 1\n \n for i in ids:\n i -= 1 # to 0based\n #########################################################\n \n \n self.tree[i] = self.func(\n self.tree[2 * i + 1], self.tree[2 * i + 2])\n #########################################################\n\n def query(self, l, r):\n \n if r <= l:\n return ValueError('invalid index (l,rがありえないよ)')\n \n self._lazyprop(*_gidx(l, r, self.num))\n \n l += self.num\n r += self.num\n res = self.ide\n while l < r: \n if r & 1:\n r -= 1\n res = self.func(res, self.tree[r - 1])\n if l & 1:\n res = self.func(res, self.tree[l - 1])\n l += 1\n l >>= 1\n r >>= 1\n return res\n\n\nimport sys\nread = sys.stdin.readline\n\n\ndef read_ints():\n return list(map(int, read().split()))\n\n\ndef read_tuple(H):\n '''\n H is number of rows\n '''\n ret = []\n for _ in range(H):\n ret.append(tuple(map(int, read().split())))\n return ret\n\n\ndef read_col(H, n_cols):\n \n ret = [[] for _ in range(n_cols)]\n for _ in range(H):\n tmp = list(map(int, read().split()))\n for col in range(n_cols):\n ret[col].append(tmp[col])\n return ret\n\n\n\nfrom collections import defaultdict, Counter, deque\nfrom operator import itemgetter\nfrom itertools import product, permutations, combinations\nfrom fractions import gcd\nfrom bisect import bisect_left, bisect_right, insort_left, insort_right\n\n\nN, D, A = read_ints()\nXH = read_tuple(N)\n\nXH.sort()\n\nX = []\nH_cnt = []\nfor x, h in XH:\n H_cnt.append((h - 1) // A + 1)\n X.append(x)\n\nseg = LazySegmentTree(H_cnt)\n\nans = 0\nfor i in range(N):\n atk = seg.query(i, i + 1) \n if atk <= 0:\n continue\n ans += atk\n \n seg.update(i, bisect_left(X, X[i] + 2 * D + 1, lo=i), -atk)\n\nprint(ans)\n", '\n\n\n\nimport sys\nread = sys.stdin.readline\n\n\ndef read_ints():\n return list(map(int, read().split()))\n\n\ndef read_tuple(H):\n \'\'\'\n H is number of rows\n \'\'\'\n ret = []\n for _ in range(H):\n ret.append(tuple(map(int, read().split())))\n return ret\n\n\n\n#\n\n\n\n\nfrom bisect import bisect_left\n\n\ndef main():\n N, D, A = read_ints()\n XH = read_tuple(N)\n XH.sort() \n\n n_atk = [] \n X = [] \n for x, h in XH:\n n_atk.append((h - 1) // A + 1)\n X.append(x)\n\n damege = [0] * (N + 10) \n ans = 0\n \n for i, (x, n) in enumerate(zip(X, n_atk)):\n damege[i] += damege[i - 1] \n atk = max(0, n - damege[i]) \n ans += atk\n \n damege[i] += atk\n \n \n # j += 1\n \n damege[bisect_left(X, x + 2 * D + 1, lo=i)] -= atk \n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s232733834', 's330857978', 's860199361', 's672519725']
[60076.0, 59052.0, 60016.0, 48656.0]
[2107.0, 2107.0, 2107.0, 977.0]
[7338, 7145, 7208, 2025]
p02788
u186838327
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
["class BIT:\n def __init__(self, n):\n self.n = n\n self.bit = [0]*(self.n+1) # 1-indexed\n\n def init(self, init_val):\n for i, v in enumerate(init_val):\n self.add(i, v)\n\n def add(self, i, x):\n # i: 0-indexed\n i += 1 # to 1-indexed\n while i <= self.n:\n self.bit[i] += x\n i += (i & -i)\n\n def sum(self, i, j):\n # return sum of [i, j)\n \n return self._sum(j) - self._sum(i)\n\n def _sum(self, i):\n # return sum of [0, i)\n # i: 0-indexed\n res = 0\n while i > 0:\n res += self.bit[i]\n i -= i & (-i)\n return res\n\nclass RangeAddBIT:\n def __init__(self, n):\n self.n = n\n self.bit1 = BIT(n)\n self.bit2 = BIT(n)\n\n def init(self, init_val):\n self.bit2.init(init_val)\n\n def add(self, l, r, x):\n # add x to [l, r)\n # l, r: 0-indexed\n self.bit1.add(l, x)\n self.bit1.add(r, -x)\n self.bit2.add(l, -x*l)\n self.bit2.add(r, x*r)\n\n def sum(self, l, r):\n # return sum of [l, r)\n # l, r: 0-indexed\n return self._sum(r) - self._sum(l)\n\n def _sum(self, i):\n # return sum of [0, i)\n # i: 0-indexed\n return self.bit1._sum(i)*i + self.bit2._sum(i)\n\nimport sys\nimport io, os\n\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\ndef main():\n n, d, a = map(int, input().split())\n XH = []\n for i in range(n):\n x, h = map(int, input().split())\n XH.append((x-d, h))\n XH.sort()\n X = []\n H = []\n for x, h in XH:\n X.append(x)\n H.append(h)\n\n bit = RangeAddBIT(n+1)\n bit.init(H)\n import bisect\n ans = 0\n for i in range(n):\n h = bit.sum(i, i+1)\n if h > 0:\n q = (h+a-1)//a\n ans += q\n j = bisect.bisect_right(X, X[i]+2*d)\n bit.add(i, j, -q*a)\n print(ans)\n\nif __name__ == '__main__':\n main()\n", 'n, d, a = map(int, input().split())\nl = [[0, 0] for _ in range(n)]\nfor i in range(n):\n x, h = map(int, input().split())\n l[i][0] = x\n l[i][1] = h\n \nl.sort()\nfrom collections import deque\nd = 2*d\nq = deque([])\ntotal = 0\n\nans = 0\nfor i in range(n):\n x = l[i][0]\n h = l[i][1]\n if q:\n while q[0][0] < x:\n total -= q[0][1]\n q.popleft()\n if not q:\n break\n h -= total\n if h > 0:\n num = (h+a-1)//a\n ans += num\n damage = num*a\n total += damage\n q.append([x+d, damage])\n\nprint(ans)']
['Time Limit Exceeded', 'Accepted']
['s077946999', 's386204258']
[59916.0, 53956.0]
[2208.0, 1230.0]
[2022, 520]
p02788
u218071226
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['\n#include <map>\ntypedef int64_t int64;\nusing namespace std;\n\n\n\nint main() {\n\tint64 n, d, a;\n\tcin >> n;\n\tcin >> d;\n\tcin >> a;\n\tmap<int64, pair<int64, int64>> m;\n\tfor (int64 i=0; i<n; i++) {\n\t\tint64 b, c;\n\t\tcin >> b;\n\t\tcin >> c;\n\t\tm[b] = {c, 0};\n\t}\n\tint64 destroy = 0;\n\tint64 bombs = 0;\n\n\tfor (auto [x, values]: m) {\n\t\tauto [health, update] = values;\n\t\thealth -= destroy;\n\t\tif (health > 0) {\n\t\t\tint64 times = (health-1) / a + 1;\n\t\t\tbombs += times;\n\t\t\tif (d==0) continue;\n\t\t\tdestroy += times*a;\n\t\t\tif (m.count(x+2*d)) m[x+2*d] = {m[x+2*d].first, times};\n\t\t\telse m[x+2*d] = {0, times};\t\n\t\t}\n\t\tdestroy -= update*a;\n\t}\n\tcout << bombs;\n\treturn 0;\n\t\t\t\n}\t\n', 'n, d, a = map(int, input().split())\n\nD = True\n\npos = []\n\nfor i in range(n):\n\tx, h = map(int, input().split())\n\tpos.append((x, h))\n\npos.sort(key=lambda x: x[0])\n\nbombs = 0\n\nfor i, (x, h) in enumerate(pos):\n\tif h <= 0:\n\t\tcontinue\n\tnew_x = x + 2*d\n\tnumber = (h-1) // a + 1\n\tbombs += number\n\tdestroy = number*a\n\tfor j, (x1, h1) in enumerate(pos[i:]):\n\t\tif x1 > new_x:\n\t\t\tbreak\n\t\tpos[j] = (x1, max(0, h1-destroy))\n\nprint(bombs)\n\t\t\n\t\n', 'n, d, a = map(int, input().split())\n\nD = True\n\npos = []\npos1 = []\n\nfor i in range(n):\n\tx, h = map(int, input().split())\n\tpos.append((x, h))\n\npos.sort(key=lambda x: x[0])\n\nbombs = 0\ndamage = 0\ny, z = 0, 0\n\n\nwhile y < n:\n\tx0 = pos[y][0]\n\ttry:\n\t\tx1 = pos1[z][0]\n\texcept IndexError:\n\t\tx1 = 1e16\n\tif x0 <= x1:\n\t\thealth = pos[y][1]\n\t\thealth -= damage\n\t\tnumber = max(0, (health-1) // a + 1)\n\t\tbombs += number\n\t\tdamage += number*a\n\t\tpos1.append((x0+2*d, number*a))\n\t\ty+=1\n\telse:\n\t\tdamage -= pos1[z][1]\n\t\tz += 1\n\t\n\nprint(bombs)\n\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s675929874', 's749080969', 's336567838']
[2940.0, 50580.0, 57316.0]
[19.0, 2107.0, 1260.0]
[666, 428, 520]
p02788
u222668979
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['def binary(N, LIST, num): \n l, r = -1, N\n while r - l > 1:\n if LIST[(l + r) // 2] > num: \n r = (l + r) // 2\n else:\n l = (l + r) // 2\n return r + 1\n\n\nn, d, a = map(int, input().split())\nxh = sorted(map(int, input().split()) for _ in range(n))\nx = [i for i, j in xh]\nh = [(j + a - 1) // a for i, j in xh]\n\nbomb, bsum, ans = [0] * (n + 1), [0] * (n + 1), 0\nfor i in range(n):\n j = binary(n, x, x[i] + 2 * d) - 1\n bnum = max(h[i] - (bsum[i - 1] + bomb[i]), 0)\n bomb[i] += bnum\n bomb[j] -= bnum\n bsum[i] += bsum[i - 1] + bomb[i]\n ans += bnum\nprint(ans)\n', 'def binary(N, LIST, num): \n l, r = -1, N\n while r - l > 1:\n if LIST[(l + r) // 2] > num: \n r = (l + r) // 2\n else:\n l = (l + r) // 2\n return r + 1\n\n\nn, d, a = map(int, input().split())\nxh = sorted(list(map(int, input().split())) for _ in range(n))\nx = [i for i, j in xh]\nh = [(j + a - 1) // a for i, j in xh]\n\nbomb, bsum, ans = [0] * (n + 1), [0] * (n + 1), 0\nfor i in range(n):\n j = binary(n, x, x[i] + 2 * d) - 1\n bnum = max(h[i] - (bsum[i - 1] + bomb[i]), 0)\n bomb[i] += bnum\n bomb[j] -= bnum\n bsum[i] += bsum[i - 1] + bomb[i]\n ans += bnum\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s855982754', 's526661145']
[96124.0, 69884.0]
[605.0, 1826.0]
[667, 673]
p02788
u260216890
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['N,D,A=map(int,input().split())\nXH=[]\nfor _ in range(N):\n x,h=map(int,input().split())\n XH.append([x,h])\nXH=sorted(XH, key=lambda x:x[0])\nX=[XH[i][0] for i in range(N)]\nH=[XH[i][1] for i in range(N)]\n\nfrom bisect import bisect_right\nimport numpy as np\nH=np.array(H)\nans=0\njs=[bisect_right(X, 2*D+X[i]) for i in range(N)]\n', 'N,D,A=map(int,input().split())\nXH=[]\nfor _ in range(N):\n x,h=map(int,input().split())\n XH.append([x,h])\nXH=sorted(XH, key=lambda x:x[0])\nX=[XH[i][0] for i in range(N)]\nH=[XH[i][1] for i in range(N)]\nfrom math import ceil\nfrom bisect import bisect_right\nimos=[0]*(N+1)\nhit=0\nans=0\nfor i in range(N):\n hit+=imos[i]\n restH=H[i]-hit*A\n if restH>0:\n ans+=ceil(restH/A)\n hit+=ceil(restH/A)\n ind=bisect_right(X,X[i]+2*D)\n imos[ind]-=ceil(restH/A)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s727315219', 's289400689']
[56372.0, 47296.0]
[1270.0, 1383.0]
[322, 467]
p02788
u268554510
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['N,D,A = map(int,input().split())\nimport numpy as np\nimport math\nXH = [list(map(int,input().split())) for _ in range(N)]\nXH = sorted(XH)\nans = 0\nl=[0]*N\nx = XH[0][0]\nj = 0\nwhile True:\n if j+1>=N:\n break\n if XH[j+1][0]<=x+D:\n j+=1\n else:\n break\nl[0]=j\nfor i in range(1,N):\n x = XH[i][0]\n j = l[i-1]\n while True:\n if j+1>=N:\n break\n if XH[j+1][0]<=x+D:\n j+=1\n else:\n break\n l[i]=j\nH = np.array([xh[1] for xh in XH])\nfor i,a in enumerate(l):\n h = H[i]\n if h<=0:\n continue\n else:\n b = math.ceil(h/A)\n ans += b\n H[i:l[a]+1:]-=b*A\nprint(ans)', 'def main():\n N,D,A = map(int,input().split())\n XH = [list(map(int,input().split())) for _ in range(N)]\n XH = sorted(XH)\n ans = 0\n S = [0]*(N+1)\n x = XH[0][0]\n h = XH[0][1]\n j = 0\n b = (h+A-1)//A\n ans += b\n y = b*A\n while True:\n if j+1>=N:\n break\n if XH[j+1][0]<=x+2*D:\n j+=1\n else:\n break\n S[0]+=y\n S[j+1]-=y\n S[1]+=S[0]\n for i in range(1,N):\n xh = XH[i]\n h = xh[1]\n s = S[i]\n rec = h-s\n if rec<=0:\n S[i+1]+=s\n continue\n else:\n x = xh[0]\n j = max(j,i)\n while True:\n if j+1>=N:\n break\n if XH[j+1][0]<=x+2*D:\n j+=1\n else:\n break\n b = (rec+A-1)//A\n ans += b\n y = b*A\n S[i]+=y\n S[j+1]-=y\n S[i+1]+=s+y\n print(ans)\nmain()']
['Wrong Answer', 'Accepted']
['s622606991', 's145130754']
[71796.0, 59736.0]
[2112.0, 1248.0]
[589, 777]
p02788
u314050667
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
["import numpy as np\nimport sys\nN, D, A = map(int, input().split())\nL = 2 * D\nI = np.array(sys.stdin.read().split(), np.int64)\nX = I[::2]\nH = I[1::2]\nsort_ind = np.argsort(X)\nX = X[sort_ind]\nH = H[sort_ind]\nS = np.zeros(N+1, np.int64)\n\natack = 0\nans = 0\nfor i in range(N):\n\tatack += S[i]\n\tH[i] -= atack\n\tif H[i] > 0:\n\t\tatack_cnt = -(-H[i]//A)\n\t\tans += atack_cnt\n\t\ttmp = atack_cnt\n\t\tS[i+1] += tmp\n\t\tind = np.searchsorted(X,X[i]+L+1,side = 'left')\n\t\tS[ind] -= tmp\n\nprint(ans)", "import numpy as np\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN, D, A = map(int, input().split())\n\nI = np.array(read().split(), np.int64)\nX = I[::2]\nH = I[1::2]\n\nsort_ind = np.argsort(X)\nX = X[sort_ind]\nH = H[sort_ind]\n\natack = np.zeros(N+1)\ncover = np.searchsorted(X, X + (2 * D), side = 'right')\n\nans = 0\ncnt = 0\nfor i in range(N):\n\tcnt += atack[i]\n\tH[i] -= cnt\n\tif H[i] > 0:\n\t\ttmp = -(-H[i]//A)\n\t\tans += tmp\n\t\tcnt += tmp * A\n\t\tatack[cover[i]] -= tmp * A\n\nprint(ans)", "import numpy as np\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\nN, D, A = map(int, input().split())\n\nI = np.array(read().split(), np.int64)\nX = I[::2]\nH = I[1::2]\n\nsort_ind = np.argsort(X)\nX = X[sort_ind]\nH = H[sort_ind]\n\natack = np.zeros(N+1, np.int64)\ncover = np.searchsorted(X, X + (2 * D), side = 'right')\n\nans = 0\ncnt = 0\nfor i in range(N):\n\tcnt += atack[i]\n\tH[i] -= cnt\n\tif H[i] > 0:\n\t\ttmp = -(-H[i]//A)\n\t\tans += tmp\n\t\tcnt += tmp * A\n\t\tatack[cover[i]] -= tmp * A\n\nprint(ans)"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s567889714', 's648133713', 's491684172']
[60360.0, 38464.0, 60192.0]
[2109.0, 2110.0, 1585.0]
[471, 542, 531]
p02788
u333700164
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from collections import deque\nn,d,a=map(int,input().split())\nxh=[map(int,input().split()) for _ in range(n)]\nxh.sort()\nD=2*D\nans=0\ntotal=0\nq=deque()\nfor i in range(n):\n x,h=xh[i]\n while len(q)>=1 and x>q[0][0]:\n total-=q.popleft()[1]\n h-=total\n if h>0:\n num=(h-h%a)//a\n damage=a*nim\n ans+=num\n total+=damage\n q.append([x+D,damage])\nprint(ans)', 'from collections import deque\nn,d,a=map(int,input().split())\nxh=[list(map(int,input().split())) for _ in range(n)]\nxh.sort()\nd=2*d\nans=0\ntotal=0\nq=deque()\nfor i in range(n):\n x,h=xh[i]\n while len(q)>=1 and x>q[0][0]:\n total-=q.popleft()[1]\n h-=total\n if h>0:\n num=(h-1//a)+1\n damage=a*num\n ans+=num\n total+=damage\n q.append([x+d,damage])\nprint(ans)\n', 'from collections import deque\nn,d,a=map(int,input().split())\nxh=[list(map(int,input().split())) for _ in range(n)]\nxh.sort()\nd=2*d\nans=0\ntotal=0\nq=deque()\nfor i in range(n):\n x,h=xh[i]\n while len(q)>=1 and x>q[0][0]:\n total-=q.popleft()[1]\n h-=total\n if h>0:\n num=(h-1)//a+1\n damage=a*num\n ans+=num\n total+=damage\n q.append([x+d,damage])\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s381431090', 's722741418', 's541202936']
[96328.0, 62192.0, 62028.0]
[712.0, 963.0, 986.0]
[364, 371, 371]
p02788
u353402627
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from collections import deque\nn, d, a = map(int, input().split())\n\nmons = []\n\nfor i in range(n):\n x, h = map(int, input().split())\n mons.append((x, h))\n\nmons = sorted(mons)\n\nprint(mons)\n\nq = deque()\n\ndm_sum = 0\n\nans = 0\n\nfor i in range(n):\n while dm_sum > 0:\n if q[0][0] < mons[i][0]:\n cur = q.popleft()\n dm_sum -= cur[1]\n else:\n break\n if mons[i][1] <= dm_sum:\n continue\n rem = mons[i][1] - dm_sum\n at_num = rem // a\n if rem % a != 0:\n at_num += 1\n ans += at_num\n\n q.append((mons[i][0] + 2 * d, at_num*a))\n dm_sum += at_num*a\n\nprint(ans)\n', 'from collections import deque\nn, d, a = map(int, input().split())\n\nmons = []\n\nfor i in range(n):\n x, h = map(int, input().split())\n mons.append((x, h))\n\nmons = sorted(mons)\n\nq = deque()\n\ndm_sum = 0\n\nans = 0\n\nfor i in range(n):\n while dm_sum > 0:\n if q[0][0] < mons[i][0]:\n cur = q.popleft()\n dm_sum -= cur[1]\n else:\n break\n if mons[i][1] <= dm_sum:\n continue\n rem = mons[i][1] - dm_sum\n at_num = rem // a\n if rem % a != 0:\n at_num += 1\n ans += at_num\n\n q.append((mons[i][0] + 2 * d, at_num*a))\n dm_sum += at_num*a\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s600272254', 's468017520']
[49804.0, 44640.0]
[1257.0, 1180.0]
[630, 617]
p02788
u446774692
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['#include <bits/stdc++.h>\nusing namespace std;\n\nint main() {\nlong long ans = 0;\nlong long N,D,A;\ncin >> N >> D >> A;\nvector<vector<long long>> enemies(N, vector<long long> (2));\nfor (int i = 0; i < N; i++)\n{\n cin >> enemies.at(i).at(0) >> enemies.at(i).at(1);\n}\nsort(enemies.begin(),enemies.end(),[](const vector<long long> &alpha,const vector<long long> &beta){return alpha[0] < beta[0];});\n\nqueue<vector<long long>> damage;\nlong long dmg = 0;\nfor (int i = 0; i < N; i++){\n long long x = enemies.at(i).at(0);\n long long h = enemies.at(i).at(1);\n if (damage.empty()){\n long long bomb = (h+A-1)/A;\n ans += bomb;\n dmg += bomb*A;\n damage.push({x+2*D,bomb});\n }\n else{\n while (!damage.empty()){\n vector<long long> vec;\n vec = damage.front();\n long long d = vec.at(0);\n long long bomb = vec.at(1);\n if (d < x){\n dmg -= bomb*A;\n damage.pop();\n }\n else{\n break;\n }\n }\n if (h > dmg){\n long long bomb = (h-dmg+A-1)/A;\n dmg += bomb*A;\n damage.push({x+2*D,bomb});\n ans += bomb;\n }\n \n }\n}\n\ncout << ans << endl;\n}', 'N,D,A = map(int,input().split())\nenemies = [list(map(int,input().split())) for _ in range(N)]\nenemies.sort(key=lambda x:x[0])\nans = 0\nfrom collections import deque\ndamage = deque()\ndmg = 0\nfor x,h in enemies:\n if len(damage) == 0:\n bomb = -(-h//A)\n damage.append([x+2*D,bomb])\n dmg += bomb*A\n ans += bomb\n else:\n while len(damage) > 0:\n d,bomb = damage.popleft()\n if x > d:\n dmg -= bomb*A\n else:\n damage.appendleft([d,bomb])\n break\n if h > dmg:\n bomb = -(-(h-dmg)//A)\n dmg += bomb*A\n damage.append([x+2*D,bomb])\n ans += bomb\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s360133700', 's615995821']
[2940.0, 66392.0]
[17.0, 1160.0]
[1260, 707]
p02788
u497046426
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from bisect import bisect_right\n\ndef div_ceil(x, y): return (x + y - 1) // y\n\nN, D, A = map(int, input().split())\nmonsters = [list(map(int, input().split())) for _ in range(N)]\nmonsters = sorted(monsters, key=lambda x: x[0])\nposition = [x for x, _ in monsters]\nans = 0\ni = 0\nwhile i < N:\n x, hp = monsters[i]\n if hp <= 0: continue\n i = bisect_right(position, x + 2*D) + 1\n attack = div_ceil(hp, A)\n ans += attack\nprint(ans)', "from bisect import bisect_right\n\ndef div_ceil(x, y): return (x + y - 1) // y\n\nN, D, A = map(int, input().split())\nmonsters = [list(map(int, input().split())) for _ in range(N)]\nmonsters = sorted(monsters, key=lambda x: x[0])\nposition = [x for x, _ in monsters]\ndamage = [0] * (N+2)\nans = 0\nfor i, [x, hp] in enumerate(monsters, 1):\n damage[i] += damage[i-1]\n if damage[i] >= hp: continue\n hp -= damage[i]\n j = bisect_right(position, x + 2*D) + 1\n attack = div_ceil(hp, A)\n ans += attack\n dam = attack * A\n # imos's method\n damage[i] += dam\n damage[j] -= dam\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s529585843', 's579865713']
[56784.0, 63232.0]
[1170.0, 1479.0]
[438, 598]
p02788
u557494880
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['N,D,A = map(int,input().split())\nd = {}\nE = []\nfor i in range(N):\n x,h = map(int,input().split())\n d[x] = h\n E.append(x)\nE.sort()\nans = 0\nimport bisect\nfor i in range(N):\n x = E[i]\n if d[x] <= 0:\n continue\n y = bisect.bisect_right(E,x+2*D)\n ans += d[x]\n for j in range(i,y):\n d[j] -= d[x]\nprint(ans)', 'N,D,A = map(int,input().split())\nattack_number = {}\nEnemy = []\nimport math\nfor i in range(N):\n x,h = map(int,input().split())\n n = math.ceil(h/A)\n attack_number[x] = n\n Enemy.append(x)\nEnemy.sort()\nbomb_number = [0 for i in range(N+1)]\nF = {}\nimport bisect\nfor i in range(N):\n x = Enemy[i]\n y = bisect.bisect_right(Enemy,x+2*D)\n F[i] = y\nans = 0\nfor i in range(N):\n if i > 0:\n bomb_number[i] += bomb_number[i-1]\n x = attack_number[Enemy[i]] - bomb_number[i]\n if x <= 0:\n continue\n y = F[i]\n bomb_number[i] += x\n bomb_number[y] -= x\n ans += x\nprint(ans)']
['Runtime Error', 'Accepted']
['s634681057', 's522636141']
[33928.0, 66828.0]
[717.0, 1208.0]
[337, 608]
p02788
u559196406
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
["import numpy as np\nn,d,a = map(int,input().split())\nx = np.zeros(n)\nh = x.copy()\nfor i in range(n):\n x[i],h[i] = map(int,input().split())\n \nind = np.argsort(x)\nind2 = np.arange(n)\nx = np.sort(x)\nh[ind2] = h[ind]\n\ndef calc(x,h):\n if 2*d >= x[-1]-x[0]:\n b = np.max(h)\n ans = b//a + min(1,b%a)\n else:\n ans1 = h[0]//a + min(1,h[0]%a)\n ans2 = h[-1]//a + min(1,h[-1]%a)\n ans = ans1 + ans2\n h[:np.searchsorted(x,x+2*d,side='right')] -= ans1*a\n h[np.searchsorted(x,x[-1]-2*d,side='left'):] -= ans2*a\n c = np.where(h > 0)[0]\n if len(c) > 0:\n x_ = x[c[0]:c[-1]+1]\n h_ = h[c[0]:c[-1]+1]\n ans += calc(x_,h_)\n \n return ans\n\nprint(int(calc(x,h)))", 'from collections import deque\nfrom math import ceil\n\nn,d,a = map(int,input().split())\nxh = sorted([list(map(int,input().split())) for _ in range(n)])\n\nq = deque()\nans = 0\ncount = 0\ntotal = 0\nfor x,h in xh:\n while q:\n if q[0][0] < x:\n total -= q.popleft()[1]\n else:\n break\n \n if total < ceil(h/a):\n count = ceil(h/a)-total\n ans += count\n total += count\n q.append((x+2*d,count))\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s795970056', 's834289438']
[31296.0, 66392.0]
[984.0, 1544.0]
[746, 461]
p02788
u563676207
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from collections import deque\n\n# input\nN, D, A = map(int, input().split())\nXH = [tuple(map(int, input().split())) for _ in range(N)]\n\n# process\nXH.sort()\nprint(XH)\n\nans = 0\ndq = deque()\ndam = 0\nfor x, h in XH:\n while dq:\n x2, h2 = dq[0]\n if x > x2:\n dam -= h2\n dq.popleft()\n else:\n break\n\n h -= dam\n if h <= 0:\n continue\n\n c = -(-h//A)\n ans += c\n d = A*c\n dam += d\n dq.append((x+D*2, d))\n \n# output\nprint(ans)\n', 'import math\n\n# input\nN, D, A = map(int, input().split())\nXH = [list(map(int, input().split())) for _ in range(N)]\n\n# process\nXH.sort()\nprint(XH)\n\nans = 0\nfor i in range(N):\n x, h = XH[i]\n if h <= 0:\n continue\n\n XH[i][1] = 0\n ans += math.ceil(h/A)\n\n for j in range(i, N):\n xhj = XH[j]\n if xhj[0] <= x+D*2:\n if xhj[1] > 0:\n xhj[1] -= h\n else:\n break\n \n print(XH)\n\n# output\nprint(ans)\n', 'from collections import deque\n\n# input\nN, D, A = map(int, input().split())\nXH = [tuple(map(int, input().split())) for _ in range(N)]\n\n# process\nXH.sort()\n#print(XH)\n\nans = 0\ndq = deque()\ndam = 0\nfor x, h in XH:\n while dq:\n x2, h2 = dq[0]\n if x > x2:\n dam -= h2\n dq.popleft()\n else:\n break\n\n h -= dam\n if h <= 0:\n# print("x,h,dam: {},{},{}".format(x,h,dam))\n continue\n\n c = -(-h//A)\n ans += c\n d = A*c\n dam += d\n dq.append((x+D*2, d))\n# print("x,h,dam,ans,dq: {},{},{},{},{}".format(x,h,dam,ans,dq))\n \n# output\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s080881672', 's410220830', 's272314333']
[49256.0, 116828.0, 44608.0]
[1156.0, 2107.0, 1028.0]
[498, 468, 619]
p02788
u572122511
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from collections import deque\nN, D, A = list(map(int, input().split()))\nD *= 2\npair_xh = [[-1, -1] for _ in range(N)]\nfor i in range(N):\n pair_xh[i][0], pair_xh[i][1] = list(map(int, input().split()))\n\nq_lim_d = deque() \ntotal = 0 \ncount = 0 \nfor i in range(N):\n x = pair_xh[i][0]\n h = pair_xh[i][1]\n \n while len(q_lim_d) and q_lim_d[0][0] < x: \n total -= q[0][1]\n q_lim_d.pop()\n h -= total\n \n if h > 0: \n times = int((h + A - 1) / A) \n count += times\n damage = A * times\n total += damage\n q_lim_d.append([x+D, damage])\nprint(count)', 'from collections import deque\nN, D, A = list(map(int, input().split()))\npair_xh = [[-1, -1] for _ in range(N)] \nfor i in range(N):\n pair_xh[i][0], pair_xh[i][1] = list(map(int, input().split()))\npair_xh.sort(key = lambda x: x[0]) \n\nq_lim_d = deque() \ntotal = 0 \ncount = 0 \nfor i in range(N):\n x = pair_xh[i][0]\n h = pair_xh[i][1]\n \n while len(q_lim_d) and q_lim_d[-1][0] < x: \n total -= q_lim_d[-1][1]\n q_lim_d.pop()\n h -= total\n if h > 0: \n times = (h + A - 1) // A \n count += times\n damage = A * times\n total += damage\n q_lim_d.appendleft([x + 2 * D, damage])\nprint(count)']
['Runtime Error', 'Accepted']
['s914241384', 's078632082']
[53952.0, 53928.0]
[954.0, 1292.0]
[930, 1051]
p02788
u600402037
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['import sys\nsys.setrecursionlimit(10 ** 7)\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN, D, A = lr()\nXH = [lr() for _ in range(N)]\nXH.sort(key=lambda x:x[0])\n\nover = [N] * (N+1) \ncur = 1\nfor i in range(N):\n while cur <= N and XH[i][0] + D + D >= XH[cur][0]:\n cur += 1\n over[i] = cur\n\ndamage = 0 \nreset = [0] * (N+1) \nanswer = 0\nfor i in range(N):\n x, h = XH[i]\n damage -= reset[i]\n h = h - damage\n time = (h+A-1)//A\n answer += time\n damage += A * time\n reset[over[i]] += A * time\n\nprint(answer)\n# 00\n', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\ndef main():\n N,D,A = map(int,readline().split())\n m = map(int,read().split())\n X,H = zip(*sorted(zip(m,m)))\n \n over = [-1]*N\n tmp=0\n for i in range(N):\n while(tmp<N and X[i]+D*2>=X[tmp]):\n tmp += 1\n over[i] = tmp\n reset = [0]*N\n \n ans = 0\n dam = 0\n for i in range(N):\n if i>0:\n reset[i] += reset[i-1]\n hp = H[i]-dam+reset[i]\n if hp > 0:\n bomb = (hp+A-1)//A\n ans += bomb\n dam += bomb * A\n if(over[i]<N):\n reset[over[i]] += bomb * A\n\n print(ans)\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s193931903', 's000966281']
[59700.0, 52936.0]
[813.0, 795.0]
[869, 715]
p02788
u638057737
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from math import ceil\nfrom collections import deque\n\nN,D,A = map(int,input().split())\nmonsters = sorted([list(map(int,input().split())) for _ in range(N)])\n\nq = deque([])\ns = 0\n\nans = 0\nfor i in range(N):\n print(q)\n while len(q) > 0 and q[0][0] < monsters[i][0]:\n s -= q[0][1]\n q.popleft()\n\n h = monsters[i][1] - s * A\n if h > 0:\n num_bombs = ceil(h / A)\n\n q.append((monsters[i][0] + 2 * D, num_bombs))\n s += num_bombs\n ans += num_bombs\n \nprint(ans)\n', 'from math import ceil\nfrom collections import deque\n\nN,D,A = map(int,input().split())\nmonsters = sorted([list(map(int,input().split())) for _ in range(N)])\n\nq = deque([])\ns = 0\n\nans = 0\nfor i in range(N):\n while len(q) > 0 and q[0][0] < monsters[i][0]:\n s -= q[0][1]\n q.popleft()\n\n h = monsters[i][1] - s * A\n if h > 0:\n num_bombs = ceil(h / A)\n\n q.append((monsters[i][0] + 2 * D, num_bombs))\n s += num_bombs\n ans += num_bombs\n \nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s008955688', 's595141920']
[128552.0, 66368.0]
[2107.0, 1389.0]
[475, 464]
p02788
u686230543
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['n, d, a = map(int, input().split())\nmonster = []\nfor _ in range(n):\n x, h = map(int, input().split())\n monster.append([x, h])\nmonster.sort()\nbomb = 0\nj = 0\nfor i in range(n):\n while j < n and monster[j][0] - monster[i][0] <= 2 * d:\n j += 1\n if monster[i][1] <= 0:\n continue\n print(type(a))\n b = (monster[i][1] - 1) // a + 1\n atk = a * b\n bomb += b\n for k in range(i+1, j):\n monster[k][1] -= atk\nprint(bomb)', 'n, d, a = map(int, input().split())\nmonster = []\nfor _ in range(n):\n x, h = map(int, input().split())\n monster.append((x, h))\nmonster.sort()\nbomb = 0\nj = 0\nfor i in range(n):\n while monster[j][0] - monster[i][0] <= 2 * d and j < n:\n j += 1\n if monster[i][1] <= 0:\n continue\n b = (monster[i][1] - 1) // a + 1\n atk = a * b\n bomb += b\n for k in range(i+1, j):\n monster[k][1] -= atk\nprint(bomb)', 'import heapq\nfrom collections import deque\n\nn, d, a = map(int, input().split())\nmonster = []\nfor _ in range(n):\n x, h = map(int, input().split())\n heapq.heappush(monster, (x, h))\nbomb = 0\ndamage = 0\nqueue = deque()\nwhile monster:\n x, h = heapq.heappop(monster)\n while True:\n if queue and x > queue[0][0]:\n damage -= queue.popleft()[1]\n else:\n break\n h -= damage\n if h <= 0:\n continue\n b = (h - 1) // a + 1\n bomb += b\n queue.append((x + 2 * d, a * b))\n damage += a * b\nprint(bomb)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s670992029', 's798832476', 's121493638']
[39108.0, 30936.0, 34832.0]
[2106.0, 1114.0, 1259.0]
[424, 407, 508]
p02788
u700805562
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['n, d, a = map(int, input().split())\nx = []\nh = []\nfor i in range(n):\n x_, h_ = map(int, input().split())\n x.append(x_)\n h.append(h_)\nn_list = range(max(x))\n\ncount = 0\nj = 0\n\nfor i in range(n):\n if x[i] > 0:\n print(h)\n s = x[i]\n bakuha = (h[i]//a)\n h[i] = 0\n count += bakuha\n if i < n-1:\n j = i+1\n while x[j] <= s+(2*d):\n h[j] -= bakuha*a\n if j < n-1:\n j += 1\n if h[j] <= 0:\n h[j] = 0\n break\n else:\n break\nprint(count)\n\n', 'from collections import deque\nn, d, a = map(int, input().split())\nxh = [list(map(int, input().split())) for i in range(n)]\nxh.sort()\nque = deque()\nans = 0\natk = 0\nfor x, h in xh:\n while que and que[0][0] <= x:\n atk -= que.popleft()[1]\n h -= a*atk\n if h <= 0:\n continue\n count = -(-h//a)\n ans += count\n atk += count\n que.append((x+2*d+1, count))\nprint(ans)']
['Runtime Error', 'Accepted']
['s174814984', 's667292957']
[156648.0, 66368.0]
[2105.0, 1246.0]
[643, 390]
p02788
u708255304
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['N, D, A = map(int, input().split())\nmonster = []\nfor _ in range(N):\n x, h = map(int, input().split())\n h = h // A\n if h % A != 0:\n h += 1\n monster.append((x, h))\n\nmonster = sorted(monster, key=lambda x: [x[0], -x[1]])\nrightest = monster[0][0] + D \nnow_bakudan = monster[0][1]\nans = monster[0][1]\n\nfor x, h in monster:\n if x > rightest+D: \n now_bakudan = 0\n if h > now_bakudan:\n ans += h-now_bakudan\n now_bakudan += h\n rightest = x+D\n\nprint(ans)\n', 'import math\nfrom bisect import bisect_right\nN, D, A = map(int, input().split()) \nXH = []\nX = []\nfor _ in range(N):\n x, h = map(int, input().split())\n XH.append(x, math.ceil(x/A)) \n X.append(x) \n\nXH.sort()\nX.sort()\nT = [0]*(N+1)\nj = 0\nnow = 0\nans = 0\nfor i in range(N):\n x, h = XH[i]\n now -= T[i]\n if now >= h:\n continue\n else:\n T[bisect_right(X, x+D*2)] += h - now\n ans += h - now\n now = h\nprint(ans)', 'import math\nfrom bisect import bisect_right \n\nN, D, A = map(int, input().split()) \nXH = []\nX = []\nfor _ in range(N):\n x, h = map(int, input().split())\n XH.append((x, math.ceil(h/A)))\n X.append(x)\n\nXH.sort()\nX.sort()\n\nnow = 0\nans = 0\nT = [0]*(N+1) \nfor i in range(N):\n x, h = XH[i] \n now -= T[i] \n if now >= h: \n continue\n else:\n ans += h - now \n T[bisect_right(X, x+2*D)] += h - now \n now = h \nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s042916684', 's187172762', 's136095464']
[60288.0, 3188.0, 40252.0]
[1341.0, 18.0, 1294.0]
[661, 667, 1138]
p02788
u729133443
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['def main():\n import sys\n from bisect import bisect\n M=10**12\n b=sys.stdin.buffer\n n,d,a=map(int,b.readline().split())\n m=map(int,b.read().split())\n c=[0]*(n+1)\n z=sorted(x*M+h for x,h in zip(m,m))\n s=0\n for i,x in enumerate(z):\n h=x%M\n c[i]+=c[i-1]\n h-=c[i]\n t=-h//a\n if t>0:t=0\n c[i]-=t*a\n c[bisect(z,x+d+d)]+=t*a\n s-=t\n print(s)\nmain()', 'def main():\n import sys\n from bisect import bisect\n M=10**10\n b=sys.stdin.buffer\n n,d,a=map(int,b.readline().split())\n m=map(int,b.read().split())\n c=[0]*(n+1)\n z=sorted(x*M+h for x,h in zip(m,m))\n s=0\n for i,x in enumerate(z):\n h=x%M\n c[i]+=c[i-1]\n h-=c[i]\n t=-h//a\n if t>0:t=0\n c[i]-=t*a\n c[bisect(z,x+d+d)]+=t*a\n s-=t\n print(s)\nmain()', 'def main():\n import sys\n from collections import deque\n from operator import itemgetter\n b=sys.stdin.buffer\n n,d,a=map(int,b.readline().split())\n m=map(int,b.read().split())\n p,q=deque(),deque()\n pl,ql=p.popleft,q.popleft\n pa,qa=p.append,q.append\n s=b=0\n for x,h in sorted(zip(m,m),key=itemgetter(0)):\n while p and p[0]<x:\n f()\n b-=g()\n h-=b\n t=0--h//a\n if t>0:\n s+=t\n b+=t*a\n pa(x+d+d)\n qa(t*a)\n print(s)\nmain()', 'def main():\n import sys\n from collections import deque\n from operator import itemgetter\n b=sys.stdin.buffer\n n,d,a=map(int,b.readline().split())\n d*=2\n m=map(int,b.read().split())\n q=deque()\n popleft,append=q.popleft,q.append\n s=b=0\n for x,h in sorted(zip(m,m),key=itemgetter(0)):\n while q and q[0][0]<x:b-=popleft()[1]\n if h>b:\n t=(b-h)//a\n s-=t\n t*=a\n b-=t\n append((x+d,-t))\n print(s)\nmain()']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s153068767', 's193658731', 's984866994', 's576209651']
[36696.0, 36184.0, 56136.0, 55752.0]
[486.0, 488.0, 273.0, 447.0]
[426, 426, 542, 498]
p02788
u729417323
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['# --*-coding:utf-8-*--\n\nimport math\n\nN,D,A = map(int, input().split())\nXH = sorted(tuple(map(int, input().split())) for _ in range(N))\n\nQ = []\nqIdx = 0\ns = 0\nt = 0\n\nfor (x, h) in XH:\n while qIdx < len(Q) and Q[qIdx][0] < x:\n s -= Q[qIdx][1]\n qIdx += 1\n\n if s < h:\n q = int(math.ceil((h-s)/A))\n Q.append((x+2*D, q))\n s += q\n t += q\n\nprint(t)\n \n \n', '# --*-coding:utf-8-*--\n\nimport math\n\nN,D,A = map(int, input().split())\nXH = sorted(tuple(map(int, input().split())) for _ in range(N))\n\nQ = []\nqIdx = 0\ns = 0\nt = 0\n\nfor (x, h) in XH:\n while qIdx < len(Q) and Q[qIdx][0] < x:\n s -= Q[qIdx][1]\n qIdx += 1\n\n if s < h:\n q = int(math.ceil((h-s)/A))\n Q.append((x+2*D, q*A))\n s += q*A\n t += q\n\nprint(t)\n']
['Wrong Answer', 'Accepted']
['s767364681', 's742711292']
[58596.0, 58596.0]
[1210.0, 1206.0]
[409, 395]
p02788
u769383879
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['import math\n\nn, d, a = map(int,input().split())\nxh = [[0 for i in range(2)] for j in range(n)]\nrang = [0 for i in range(n)]\nfor i in range(n):\n x,h = map(int,input().split())\n xh[i] = [x,h]\n rang[i] = x\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])]\n\ndam = [0]*n\nfor i in range(n):\n res = xh[i][1]-dam[i]\n pos = xh[i][0]\n if res > 0:\n nat = math.ceil(res/a)\n num += nat\n for j in range(i+1,n):\n if rang[j] <= pos + 2d:\n dam[j] += a*nat\n else:\n break\nprint(num)\n', 'import numpy as np\n\nn, d, a = map(int,input().split())\nxh = np.zeros((n,2), dtype = int)\nfor i in range(n):\n x,h = map(int,input().split())\n xh[i] = [x,h]\n\nnum = 0\nxh = xh[np.argsort(xh[:, 0])]\n\nwhile xh.size > 0.5:\n if xh[0,1]%a == 0:\n nat = int((xh[0,1])/a)\n else:\n nat = int((xh[0,1])/a+1)\n num += nat\n dam = nat*a\n for i in range(xh.shape[0]):\n if xh[i,0] <= xh[0,0]+2*d:\n xh[i,1] -= dam\n else:\n break\n xh = xh[np.all(xh<0.5,axis=1)]\n\nprint(num)\n', 'import math\n\nn, d, a = map(int,input().split())\nxh = []\nfor i in range(n):\n x,h = map(int,input().split())\n xh.append([x,h])\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\nl = len(xh)\ndam = [0]*n\n\nfor i in range(n):\n res = xh[i][1]-dam[i]\n if res > 0:\n nat = math.ceil(res/a)\n pos = xh[i][0]+d\n num += nat\n for j in range(n):\n if math.fabs(xh[j][0]-pos) <= d:\n ###dam[j] += a*nat\n\nprint(num)\n', 'import math\n\nn, d, a = map(int,input().split())\nxh = [[0 for i in range(2)] for j in range(n)]\nrang = [0 for i in range(n)]\nfor i in range(n):\n x,h = map(int,input().split())\n xh[i] = [x,h]\n rang[i] = x\nprint(xh,rang)\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\n\ndam = [0]*n\nfor i in range(n):\n res = xh[i][1]-dam[i]\n pos = xh[i][0]\n if res > 0:\n nat = math.ceil(res/a)\n num += nat\n for j in range(i+1,n):\n if rang[j]-d <= pos + d:\n dam[j] += a*nat\n else:\n break\nprint(num)\n', "import math\n\nn, d, a = map(int,input().split())\nxh = []\nfor i in range(n):\n x,h = map(int,input().split())\n xh.append([x,h])\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\nl = len(xh)\ndam = [0]*n\nrang = [0]*n\nfor i in range(n):\n rang[i] = xh[i][0]-d\n'''\nfor i in range(n):\n res = xh[i][1]-dam[i]\n if res > 0:\n nat = math.ceil(res/a)\n pos = xh[i][0]+d\n num += nat\n for j in range(n):\n if rang[j] <= pos:\n dam[j] += a*nat\n else:\n break\n'''\nprint(num)\n", "import math\n\nn, d, a = map(int,input().split())\nxh = []\nfor i in range(n):\n x,h = map(int,input().split())\n xh.append([x,h])\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\nx = []\nh = []\n\n'''\nwhile len(h) > 0.5:\n nat = math.ceil((h[0])/a)\n num += nat\n dam = nat*a\n for i in range(len(x)):\n if x[i] <= x[0]+2*d:\n h[i] -= dam\n else:\n break\n while len(h) > 0 and h[0] < 0.5:\n h.pop(0)\n x.pop(0)\n'''\n\nprint(num)\n", 'import math\n\nn, d, a = map(int,input().split())\nxh = []\nfor i in range(n):\n x,h = map(int,input().split())\n xh.append([x,h])\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\nl = len(xh)\ndam = [0]*n\nrang = [0]*n\nfor i in range(n):\n rang[i] = xh[i][0]\n\nfor i in range(n):\n res = xh[i][1]-dam[i]\n if res > 0:\n nat = math.ceil(res/a)\n pos = xh[i][0]+d\n num += nat\n for j in range(n):\n if rang[j] <= pos:\n dam[j] += a*nat\n\nprint(num)\n', 'import math\n\nn, d, a = map(int,input().split())\nxh = []\nfor i in range(n):\n x,h = map(int,input().split())\n xh.append([x,h])\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\nprint(xh)\n\nwhile len(xh) > 0.5:\n nat = math.ceil((xh[0][1])/a)\n num += nat\n dam = nat*a\n for i in range(len(xh)):\n if xh[i][0] <= xh[0][0]+2*d:\n xh[i][1] -= dam\n else:\n break\n xh = [i for i in xh if i[1] > 0]\n\nprint(num)\n', 'import numpy as np\nimport math\n\nn, d, a = map(int,input().split())\nxh = np.zeros((n,2), dtype = int)\nfor i in range(n):\n x,h = map(int,input().split())\n xh[i] = [x,h]\n\nnum = 0\nxh = xh[np.argsort(xh[:, 0])]\n\n\nprint(num)\n', 'import math\n\nn, d, a = map(int,input().split())\nxh = []\nfor i in range(n):\n x,h = map(int,input().split())\n xh.append([x,h])\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\nl = len(xh)\ndam = [0]*n\nrang = [0]*n\nfor i in range(n):\n rang[i] = xh[i][0]-d\n\nfor i in range(n):\n res = xh[i][1]-dam[i]\n if res > 0:\n nat = math.ceil(res/a)\n pos = xh[i][0]+d\n num += nat\n for j in range(i+1,n):\n if rang[j] <= pos:\n dam[j] += a*nat\n print(j,dam[j])\n else:\n break\nprint(num)\n', "import math\n\nn, d, a = map(int,input().split())\nxh = [[0 for i in range(2)] for j in range(n)]\nrang = [n]*(n-1)+[0]\nfor i in range(n):\n x,h = map(int,input().split())\n xh[i] = [x,h]\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\n\nfor i in range(n):\n for j in range(rang[i-1],n):\n if xh[i][0]+d < xh[j][0]-d:\n rang[i] = j\n break\n\ndam = [0]*n\nfor i in range(n):\n res = xh[i][1]-dam[i]\n pos = xh[i][0]\n if res > 0:\n nat = math.ceil(res/a)\n num += nat\n '''\n for j in range(i+1,rang[i]):\n dam[j] += a*nat\n '''\nprint(num)\n", "import math\n\nn, d, a = map(int,input().split())\nxh = [[0 for i in range(2)] for j in range(n)]\nrang = [n]*(n-1)+[0]\nfor i in range(n):\n x,h = map(int,input().split())\n xh[i] = [x,h]\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\n\nfor i in range(n):\n for j in range(rang[i-1],n):\n if xh[i][0]+d < xh[j][0]-d:\n rang[i] = j\n break\n\n'''\ndam = [0]*n\nfor i in range(n):\n res = xh[i][1]-dam[i]\n pos = xh[i][0]\n if res > 0:\n nat = math.ceil(res/a)\n num += nat\n for j in range(i+1,rang[i]):\n dam[j] += a*nat\n'''\nprint(num)\n", 'import math\n\nn, d, a = map(int,input().split())\nxh = [[0 for i in range(2)] for j in range(n)]\nrang = [n]*n\nfor i in range(n):\n x,h = map(int,input().split())\n xh[i] = [x,h]\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\n\nfor i in range(n):\n for j in range(rang[i-1],n):\n if xh[i][0]+d < xh[j][0]-d:\n rang[i] = j\n break\nprint(rang)\n\ndam = [0]*n\nfor i in range(n):\n res = xh[i][1]-dam[i]\n pos = xh[i][0]\n if res > 0:\n nat = math.ceil(res/a)\n num += nat\n for j in range(i+1,rang[i]):\n dam[j] += a*nat\n\nprint(num)\n', "import math\n\nn, d, a = map(int,input().split())\nxh = []\nfor i in range(n):\n x,h = map(int,input().split())\n xh.append([x,h])\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\nl = len(xh)\ndam = [0]*n\n\nfor i in range(n):\n res = xh[i][1]-dam[i]\n if res > 0:\n nat = math.ceil(res/a)\n pos = xh[i][0]+d\n num += nat\n'''\n for j in range(n):\n if math.fabs(xh[j][0]-pos) <= d:\n dam[j] += a*nat\n'''\n\nprint(num)\n", 'import math\n\nn, d, a = map(int,input().split())\nxh = [[0 for i in range(2)] for j in range(n)]\nleft = [i for i in range(n)]\nfor i in range(n):\n x,h = map(int,input().split())\n xh[i] = [x,h]\n\nnum = 0\nxh.sort(key=lambda xh:xh[0])\n\nfor i in range(n):\n for j in range(left[i-1],i):\n if xh[j][0]+d >= xh[i][0]-d:\n left[i] = j\n break\n\ndam = [0]*n\n\ndef dsum(k):\n if k == 0:\n return 0\n elif left[k] == 0:\n return dam[k-1]\n else:\n return dam[k-1]-dam[left[k]-1]\n\nfor i in range(n):\n res = xh[i][1]-dsum(i)\n nat = max([math.ceil(res/a),0])\n dam[i] = dam[i-1]+a*nat\n if res > 0:\n num += nat\n\nprint(num)\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s001948037', 's035168287', 's108310407', 's148138995', 's280976742', 's296205213', 's339194602', 's415895683', 's460547238', 's476264534', 's503196504', 's644106932', 's885040076', 's885728095', 's599430759']
[2940.0, 20272.0, 3064.0, 60412.0, 45708.0, 39688.0, 45708.0, 51972.0, 20260.0, 64908.0, 48792.0, 48784.0, 48852.0, 39676.0, 55272.0]
[17.0, 1723.0, 17.0, 2107.0, 893.0, 795.0, 2106.0, 2106.0, 1215.0, 2107.0, 1366.0, 1179.0, 2107.0, 983.0, 1520.0]
[544, 524, 449, 559, 535, 469, 487, 441, 496, 564, 604, 584, 581, 454, 679]
p02788
u775133993
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from collections import deque\nfrom math import ceil\n\n\nn, d, a = map(int,input().split())\n\nms = sorted([(pos, ceil(hp / a)) for pos, hp in [map(int, input().split()) for i in range(n)])\n \nbombs = deque()\n \nans = 0\nvalid_bomb = 0\nfor pos, hp in ms:\n \n while que and que[0][0] < pos:\n bomb_border, bomb_cnt = bombs.popleft()\n valid_bomb -= bomb_cnt\n \n \n bomb_cnt = max(0, hp - valid_bomb)\n valid_bomb += bomb_cnt\n ans += bomb_cnt\n \n \n if bomb_cnt > 0:\n que.append([pos + d * 2, bomb_cnt])\n \nprint(ans) \n', 'from collections import deque\nfrom math import ceil\n\n\nn, d, a = map(int, input().split())\n\nms = [map(int, input().split()) for i in range(n)]\nms = sorted([(pos, ceil(hp / a)) for pos, hp in ms])\n\nbombs = deque()\n\nans = 0\nvalid_bomb = 0\nfor pos, hp in ms:\n \n while bombs and bombs[0][0] < pos:\n bomb_border, bomb_cnt = bombs.popleft()\n valid_bomb -= bomb_cnt\n \n \n bomb_cnt = max(0, hp - valid_bomb)\n valid_bomb += bomb_cnt\n ans += bomb_cnt\n \n \n if bomb_cnt > 0:\n bombs.append([pos + d * 2, bomb_cnt])\n \nprint(ans) ']
['Runtime Error', 'Accepted']
['s646916779', 's073777170']
[8800.0, 100288.0]
[26.0, 1050.0]
[687, 734]
p02788
u780475861
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
["def main():\n import sys\n from collections import deque\n read=sys.stdin.read\n readline=sys.stdin.readline\n \n n, d, a = map(int, readline().split())\n m = map(int, read().split())\n monsters = sorted(zip(m, m), key=itemgetter(0))\n \n bomb_area = deque([])\n bomb_power = deque([])\n total_damage = 0\n ans = 0\n for pos, hp in monsters:\n while bomb_area:\n area = bomb_area[0]\n if area < pos:\n bomb_area.popleft()\n power = bomb_power.popleft()\n total_damage -= power\n else:\n break\n if hp <= total_damage:\n continue\n else:\n rest = hp - total_damage\n count = rest // a + (rest % a != 0)\n ans += count\n power = a * count\n total_damage += power\n bomb_area.append(pos + 2 * d)\n bomb_power.append(power)\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "\n\nimport numpy as np\ni8 = np.int64\n\ndef solve(X, H, D):\n xi = np.empty_like(X)\n hi = np.empty_like(H)\n p = 0\n N = X.shape[0]\n for i in range(1, N):\n if X[i] > X[i - 1]:\n xi[p] = X[i - 1]\n hi[p] = H[i - 1]\n p += 1\n xi[p] = X[N - 1]\n hi[p] = H[N - 1]\n p += 1\n area = 2 * D\n res = 0\n sum_right = 0\n sum_left = 0\n left = 0\n for i in range(p):\n while xi[i] - xi[left] > area:\n sum_left += hi[left]\n left += 1\n x = hi[i] - (sum_right - sum_left)\n if x > 0:\n res += x\n sum_right += x\n hi[i] = x\n else:\n hi[i] = 0\n return res\n\n\ndef main(X, H, D, A):\n arg = np.lexsort((H, X))\n X = X[arg]\n H = H[arg]\n H = (H - 1) // A + 1\n print(solve(X, H, D))\n\n\nif __name__ == '__main__':\n stdin = np.fromstring(open(0).read(), np.int64, sep=' ')\n N, D, A = stdin[:3]\n XH = stdin[3:].reshape((-1, 2)).T\n ans = main(XH[0], XH[1], D, A)\n"]
['Runtime Error', 'Accepted']
['s295708809', 's687745284']
[35812.0, 23392.0]
[58.0, 1100.0]
[987, 1074]
p02788
u814986259
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['import math\nN, D, A = map(int, input().split())\nXH = [list(map(int, input().split())) for i in range(N)]\nXH.sort(key=lambda x: x[0])\nleft = D\nflag = True\ncount = 0\nans = 0\nfor i in range(N):\n print(count)\n \n if i == 0 or pos + D < XH[i][0]:\n pos = XH[i][0] + D\n count = math.ceil(XH[i][1] / A)\n XH[i][1] = 0\n ans += count\n else:\n XH[i][1] -= count*A\n if XH[i][1] > 0:\n pos = XH[i][0] + D\n count = math.ceil(XH[i][1] / A)\n XH[i][1] = 0\n ans += count\n else:\n continue\n\nprint(ans)\n', 'import math\nimport collections\nN, D, A = map(int, input().split())\n\nXH = [tuple(map(int, input().split())) for i in range(N)]\nXH.sort()\nq = collections.deque()\nc = 0\nans = 0\nfor x, h in XH:\n while(q and q[0][0] < x):\n c -= q[0][1]\n q.popleft()\n h -= c * A\n if h < 0:\n h = 0\n ans += math.ceil(h/A)\n c += math.ceil(h/A)\n\n q.append((x+2*D, math.ceil(h/A)))\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s608632574', 's987597114']
[55252.0, 55724.0]
[1224.0, 1186.0]
[617, 405]
p02788
u844789719
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['import sys, heapq\ninput = sys.stdin.readline\nN, D, A = [int(_) for _ in input().split()]\nXH = [[int(_) for _ in input().split()] for _ in range(N)]\nHe = [[2 * x, h, 0] for x, h in XH]\nheapq.heapify(He)\nnow = 0\nans = 0\nwhile He:\n x, h, t = heapq.heappop(He)\n if t:\n now -= h\n else:\n if h - D * now > 0:\n diff = (h - now - 1) // A + 1\n now += diff\n ans += diff\n heapq.heappush(He, [x + 4 * D + 1, diff, 1])\nprint(ans)\n', 'import sys, heapq\ninput = sys.stdin.readline\nN, D, A = [int(_) for _ in input().split()]\nXH = [[int(_) for _ in input().split()] for _ in range(N)]\nHe = [[2 * x, h, 0] for x, h in XH]\nheapq.heapify(He)\nnow = 0\nans = 0\nwhile He:\n x, h, t = heapq.heappop(He)\n if t:\n now -= h\n else:\n if h - A * now > 0:\n diff = (h - A * now - 1) // A + 1\n now += diff\n ans += diff\n heapq.heappush(He, [x + 4 * D + 1, diff, 1])\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s442878779', 's998880786']
[66292.0, 70132.0]
[1631.0, 1514.0]
[483, 487]
p02788
u853819426
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['from math import *\n\nn, d, a = map(int, input().split())\nn_max = 2**(ceil(log(n)/log(2)))\nhealth = [0]*(n_max * 2 - 1)\nlazy = [0]*(n_max * 2 -1)\np = sorted(tuple(map(int, input().split())) for _ in range(n))\n\nhealth[n_max-1:n_max+n-1] = (h for _, h in p)\n\ndef init2(k=0, l=0, r=n_max):\n if r-l <= 1:\n return health[k]\n s = init2(2*k+1, l, (l+r)//2)\n s += init2(2*k+2, (l+r)//2, r)\n health[k] = s\n return s\n\ndef evalue(k, l, r):\n if not lazy[k]:\n return\n health[k] = max(health[k] + lazy[k], 0)\n if r - l > 1:\n lazy[2 * k + 1] = lazy[k] // 2\n lazy[2 * k + 2] = lazy[k] // 2\n lazy[k] = 0\n \ndef add(a, b, v, k=0, l=0, r=n_max):\n evalue(k, l, r)\n if b <= l or r <= a:\n return health[k]\n if a <= l and r <= b:\n lazy[k] += v * (r - l)\n evalue(k, l, r)\n else:\n vl = add(a, b, v, 2 * k + 1, l, (l + r) // 2)\n vr = add(a, b, v, 2 * k + 2, (l + r) // 2, r)\n health[k] = vl + vr\n return health[k]\n \ndef get(a, b, k=0, l=0, r=n_max):\n if (b <= l or r <=a):\n return 0\n evalue(k, l, r)\n if a <= l and r <= b: return health[k]\n vl = get(a, b, 2 * k + 1, l, (l + r) // 2)\n vr = get(a, b, 2 * k + 2, (l + r) // 2, r)\n return max(vl, vr)\n \n\ninit2()\n#for i, (_, h) in enumerate(p):\n# init(i, i+1, h)\nc = 0\nj = 0\nimport pdb; pdb.set_trace()\nfor i in range(n):\n \n x, _ = p[i]\n h = get(i, i+1)\n if h <= 0: continue\n m = ceil(h/a)\n c += m\n m = m*a\n while j < n and p[j][0] - x <= 2 * d + 1:\n j += 1\n add(i, j, -m)\nprint(c)', 'from math import *\nimport bisect\nn, d, a = map(int, input().split())\nn_max = 2**(ceil(log(n)/log(2)))\nhealth = [0]*(n_max * 2 - 1)\nlazy = [0]*(n_max * 2 -1)\ndef evalue(k, l, r):\n if not lazy[k]:\n return\n health[k] = max(health[k] + lazy[k], 0)\n if r - l > 1:\n lazy[2 * k + 1] = lazy[k] // 2\n lazy[2 * k + 2] = lazy[k] // 2\n lazy[k] = 0\n\ndef init(a, b, h, k=0, l=0, r=n_max):\n if b <= l or r <= a:\n return health[k]\n health[k] = health[k] + h\n if r - l <= 1:\n return health[k]\n vl = init(a, b, h, 2 * k + 1, l, (l + r) // 2)\n vr = init(a, b, h, 2 * k + 2, (l + r) // 2, r)\n health[k] = vl + vr\n return health[k]\n \ndef add(a, b, v, k=0, l=0, r=n_max):\n evalue(k, l, r)\n if b <= l or r <= a:\n return health[k]\n if a <= l and r <= b:\n lazy[k] += v * (r - l)\n evalue(k, l, r)\n else:\n vl = add(a, b, v, 2 * k + 1, l, (l + r) // 2)\n vr = add(a, b, v, 2 * k + 2, (l + r) // 2, r)\n health[k] = vl + vr\n return health[k]\n\ndef get(a, b, k=0, l=0, r=n_max):\n if (b <= l or r <=a):\n return 0\n evalue(k, l, r)\n if a <= l and r <= b: return health[k]\n vl = get(a, b, 2 * k + 1, l, (l + r) // 2)\n vr = get(a, b, 2 * k + 2, (l + r) // 2, r)\n return max(vl, vr)\n\np = sorted(tuple(map(int, input().split())) for _ in range(n))\nfor i, (_, h) in enumerate(p):\n init(i, i+1, h)\n\nc = 0\nj = 0\nfor i in range(n):\n x, _ = p[i]\n h = get(i, i+1)\n if h <= 0: continue\n m = ceil(h/a)\n c += m\n m = m*a\n while j >= n or p[j][0] - x > 2 * d + 1:\n j += 1\n add(i, j, -m)\nprint(c)', 'from math import *\n\nn, d, a = map(int, input().split())\nn_max = 2**(ceil(log(n)/log(2)))\nhealth = [0]*(n_max * 2 - 1)\nlazy = [0]*(n_max * 2 -1)\np = sorted(tuple(map(int, input().split())) for _ in range(n))\n\nhealth[n_max:n_max+n] = p\ndef init2(k=0, l=0, r=n_max):\n if r-l <= 1:\n return health[k]\n s = init2(2*k+1, l, (l+r)//2)\n s += init2(2*k+2, (l+r)//2, r)\n health[k] = s\n return s\n\ndef evalue(k, l, r):\n if not lazy[k]:\n return\n health[k] = max(health[k] + lazy[k], 0)\n if r - l > 1:\n lazy[2 * k + 1] = lazy[k] // 2\n lazy[2 * k + 2] = lazy[k] // 2\n lazy[k] = 0\n \ndef init(a, b, h, k=0, l=0, r=n_max):\n if b <= l or r <= a:\n return health[k]\n health[k] = health[k] + h\n if r - l <= 1:\n return health[k]\n vl = init(a, b, h, 2 * k + 1, l, (l + r) // 2)\n vr = init(a, b, h, 2 * k + 2, (l + r) // 2, r)\n health[k] = vl + vr\n return health[k]\n \ndef add(a, b, v, k=0, l=0, r=n_max):\n evalue(k, l, r)\n if b <= l or r <= a:\n return health[k]\n if a <= l and r <= b:\n lazy[k] += v * (r - l)\n evalue(k, l, r)\n else:\n vl = add(a, b, v, 2 * k + 1, l, (l + r) // 2)\n vr = add(a, b, v, 2 * k + 2, (l + r) // 2, r)\n health[k] = vl + vr\n return health[k]\n \ndef get(a, b, k=0, l=0, r=n_max):\n if (b <= l or r <=a):\n return 0\n evalue(k, l, r)\n if a <= l and r <= b: return health[k]\n vl = get(a, b, 2 * k + 1, l, (l + r) // 2)\n vr = get(a, b, 2 * k + 2, (l + r) // 2, r)\n return max(vl, vr)\n \n\ninit2()\n#for i, (_, h) in enumerate(p):\n# init(i, i+1, h)\n \nc = 0\nj = 0\nfor i in range(n):\n x, _ = p[i]\n h = get(i, i+1)\n if h <= 0: continue\n m = ceil(h/a)\n c += m\n m = m*a\n while j >= n or p[j][0] - x > 2 * d + 1:\n j += 1\n add(i, j, -m)\nprint(c)', 'from math import *\n\nn, d, a = map(int, input().split())\nn_max = 2**(ceil(log(n)/log(2)))\nhealth = [0]*(n_max * 2 - 1)\nlazy = [0]*(n_max * 2 -1)\np = sorted(tuple(map(int, input().split())) for _ in range(n))\n\nhealth[n_max-1:n_max+n-1] = (h for _, h in p)\n\ndef init2(k=0, l=0, r=n_max):\n if r-l <= 1:\n return health[k]\n s = init2(2*k+1, l, (l+r)//2)\n s += init2(2*k+2, (l+r)//2, r)\n health[k] = s\n return s\n\ndef evalue(k, l, r):\n if not lazy[k]:\n return\n health[k] = max(health[k] + lazy[k], 0)\n if r - l > 1:\n lazy[2 * k + 1] = lazy[k] // 2\n lazy[2 * k + 2] = lazy[k] // 2\n lazy[k] = 0\n \ndef init(a, b, h, k=0, l=0, r=n_max):\n if b <= l or r <= a:\n return health[k]\n health[k] = health[k] + h\n if r - l <= 1:\n return health[k]\n vl = init(a, b, h, 2 * k + 1, l, (l + r) // 2)\n vr = init(a, b, h, 2 * k + 2, (l + r) // 2, r)\n health[k] = vl + vr\n return health[k]\n \ndef add(a, b, v, k=0, l=0, r=n_max):\n evalue(k, l, r)\n if b <= l or r <= a:\n return health[k]\n if a <= l and r <= b:\n lazy[k] += v * (r - l)\n evalue(k, l, r)\n else:\n vl = add(a, b, v, 2 * k + 1, l, (l + r) // 2)\n vr = add(a, b, v, 2 * k + 2, (l + r) // 2, r)\n health[k] = vl + vr\n return health[k]\n \ndef get(a, b, k=0, l=0, r=n_max):\n if (b <= l or r <=a):\n return 0\n evalue(k, l, r)\n if a <= l and r <= b: return health[k]\n vl = get(a, b, 2 * k + 1, l, (l + r) // 2)\n vr = get(a, b, 2 * k + 2, (l + r) // 2, r)\n return max(vl, vr)\n \n\ninit2()\n#for i, (_, h) in enumerate(p):\n# init(i, i+1, h)\nc = 0\nj = 0\nfor i in range(n):\n x, _ = p[i]\n h = get(i, i+1)\n if h <= 0: continue\n m = ceil(h/a)\n c += m\n m = m*a\n while j >= n or p[j][0] - x > 2 * d + 1:\n j += 1\n add(i, j, -m)\nprint(c)', 'from math import *\n\nn, d, a = map(int, input().split())\nn_max = 2**(ceil(log(n)/log(2)))\nhealth = [0]*(n_max * 2 - 1)\nlazy = [0]*(n_max * 2 -1)\np = sorted(tuple(map(int, input().split())) for _ in range(n))\n\nhealth[n_max-1:n_max+n-1] = (h for _, h in p)\n\ndef init2(k=0, l=0, r=n_max):\n if r-l <= 1:\n return health[k]\n s = init2(2*k+1, l, (l+r)//2)\n s += init2(2*k+2, (l+r)//2, r)\n health[k] = s\n return s\n\ndef evalue(k, l, r):\n if not lazy[k]:\n return\n health[k] = max(health[k] + lazy[k], 0)\n if r - l > 1:\n lazy[2 * k + 1] = lazy[k] // 2\n lazy[2 * k + 2] = lazy[k] // 2\n lazy[k] = 0\n \ndef init(a, b, h, k=0, l=0, r=n_max):\n if b <= l or r <= a:\n return health[k]\n health[k] = health[k] + h\n if r - l <= 1:\n return health[k]\n vl = init(a, b, h, 2 * k + 1, l, (l + r) // 2)\n vr = init(a, b, h, 2 * k + 2, (l + r) // 2, r)\n health[k] = vl + vr\n return health[k]\n \ndef add(a, b, v, k=0, l=0, r=n_max):\n evalue(k, l, r)\n if b <= l or r <= a:\n return health[k]\n if a <= l and r <= b:\n lazy[k] += v * (r - l)\n evalue(k, l, r)\n else:\n vl = add(a, b, v, 2 * k + 1, l, (l + r) // 2)\n vr = add(a, b, v, 2 * k + 2, (l + r) // 2, r)\n health[k] = vl + vr\n return health[k]\n \ndef get(a, b, k=0, l=0, r=n_max):\n if (b <= l or r <=a):\n return 0\n evalue(k, l, r)\n if a <= l and r <= b: return health[k]\n vl = get(a, b, 2 * k + 1, l, (l + r) // 2)\n vr = get(a, b, 2 * k + 2, (l + r) // 2, r)\n return max(vl, vr)\n \n\ninit2()\n#for i, (_, h) in enumerate(p):\n# init(i, i+1, h)\nprint(health)\nc = 0\nj = 0\nfor i in range(n):\n x, _ = p[i]\n h = get(i, i+1)\n if h <= 0: continue\n m = ceil(h/a)\n c += m\n m = m*a\n while j >= n or p[j][0] - x > 2 * d + 1:\n j += 1\n add(i, j, -m)\nprint(c)', 'from math import *\n\nn, d, a = map(int, input().split())\ndamage_diff = [0] * n\ndamage = 0\np = sorted(tuple(map(int, input().split())) for _ in range(n))\n\nj = 0\nc = 0\n\nfor i in range(n):\n damage -= damage_diff[i]\n \n x, h = p[i]\n h -= damage\n if h <= 0: continue\n m = ceil(h/a)\n c += m\n m = m*a\n while j < n and p[j][0] - x <= 2 * d:\n j += 1\n\n if j < n:\n damage_diff[j] += m\n damage += m\nprint(c)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s170953073', 's232135403', 's491961302', 's850482702', 's983242063', 's193478343']
[47712.0, 44188.0, 39968.0, 46116.0, 61852.0, 38020.0]
[1139.0, 2106.0, 878.0, 2106.0, 2106.0, 1177.0]
[1465, 1515, 1703, 1722, 1736, 410]
p02788
u855393458
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['import numpy as np\nn, d, a = (int(x) for x in input().split())\nxh = np.empty((0, 2))\nfor _ in range(n):\n x, h = (int(x) for x in input().split())\n xh = np.vstack((xh, np.array([x, h])))\nxh = xh[np.argsort(xh[:, 0])]\ncnt = 0\nwhile True:\n if xh[xh[:, 1] > 0].size == 0:\n break\n xx, hh = xh[(xh[:, 1] > 0)][0]\n num = hh // a\n if hh % a != 0:\n num += 1\n xh[(xh[:, 0] >= xx) & (xh[:, 0] <= xx + 2 * d), 1] -= num * a\n cnt += num\nprint(cnt)', 'n, d, a = (int(x) for x in input().split())\nxh = []\nfor _ in range(n):\n x, h = (int(x) for x in input().split())\n xh.append([x, h])\nxh = sorted(xh, key=lambda x: x[0])\ncnt = 0\nfor i, (x, h) in enumerate(xh):\n if h <= 0:\n continue\n num = h // a\n if h % a != 0:\n num += 1\n xh[i][1] -= num * a\n for j in range(i + 1, len(xh)):\n if xh[j][0] <= x + 2 * d:\n break\n if xh[j][1] > 0:\n xh[j][1] -= num * a\n cnt += num\nprint(int(cnt))', "from math import ceil\nfrom bisect import bisect_right\nn, d, a = (int(x) for x in input().split())\nxh = []\nfor _ in range(n):\n x, h = (int(x) for x in input().split())\n xh.append([x, h])\nxh = sorted(xh, key=lambda x: x[0])\ncnt = 0\ndmg = [0] * (n + 1)\nfor i, (x, h) in enumerate(xh):\n dmg[i] += dmg[i - 1]\n h -= dmg[i]\n if h <= 0:\n continue\n num = ceil(h / a)\n dmg[i] += num * a\n idx = bisect_right(xh, [x + 2 * d, float('inf')])\n dmg[idx] -= num * a\n cnt += num\nprint(cnt)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s071760196', 's627496225', 's112081426']
[15712.0, 41204.0, 44172.0]
[2108.0, 1801.0, 1608.0]
[472, 498, 508]
p02788
u932465688
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['n,d,a = map(int,input().split())\nL = []\nT = []\nU = []\nhitpoint = []\nfor i in range(n):\n p,q = map(int,input().split())\n L.append([p,q,0])\n T.append(p)\n U.append(p)\n hitpoint.append(q)\nU.sort()\nfor i in range(n):\n k = bisect.bisect_right(U,T[i]+2*d)\n L[i][2] = k\nL.sort()\nstart = 0\nans = 0\nwhile start != n:\n t = hitpoint[start]//a\n if hitpoint[start]%a == 0:\n attack = t\n else:\n attack = t+1\n ans += attack\n cur = attack*a\n look = L[start][2]\n flag = False\n ne = 0\n for i in range(look-start):\n if start+i <= n-1:\n if (hitpoint[start+i] - cur <= 0):\n hitpoint[start+i] = 0\n else:\n if not flag:\n ne = i\n flag = True\n hitpoint[start+i] -= cur\n if ne == 0:\n start += 1\n else:\n start += ne\nprint(ans)', 'import math\nimport bisect\nn,d,a = map(int,input().split())\nL = []\nkyo = []\nfor i in range(n):\n x,h = map(int,input().split())\n L.append([x,h])\n kyo.append(x)\nL.sort()\nkyo.sort()\nans = 0\nimos = [0]*(n+1)\ncur = 0\nran = 2*d\nfor i in range(n):\n if imos[cur] < L[cur][1]:\n t = int(math.ceil((L[cur][1]-imos[cur])/a))\n ans += t\n imos[cur] += t*a\n lim = bisect.bisect_right(kyo, kyo[cur]+ran)\n imos[lim] -= t*a\n imos[i+1] += imos[i]\n cur += 1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s144643743', 's514228678']
[41844.0, 46484.0]
[812.0, 1495.0]
[778, 500]
p02788
u970308980
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['N, D, A = map(int, input().split())\nmonsters = []\nfor i in range(N):\n x, h = map(int, input().split())\n monsters.append((x, h))\nmonsters.sort()\n\ndamege_sum = 0\nans = 0\nq = []\nfor i in range(N):\n x, h = monsters[i]\n while q:\n if q[0][0] < x:\n damege_sum -= q[0][1]\n q.pop(0)\n h -= damege_sum\n if h > 0:\n hit = -(-h // A)\n ans += hit\n damage = hit * A\n damege_sum += damage\n q.append((x + 2 * D, damage))\n\nprint(ans)\n\n\n', 'from math import ceil\nfrom collections import deque\n\n\nN, D, A = map(int, input().split())\nmonsters = []\nfor i in range(N):\n x, h = map(int, input().split())\n monsters.append((x, h))\nmonsters.sort()\n\n\ndamage_sum = 0\nans = 0\nq = deque([])\nfor i in range(N):\n x, h = monsters[i]\n while q and q[0][0] < x:\n damage_sum -= q[0][1]\n q.popleft()\n h -= damage_sum\n if h > 0:\n hit = ceil(h / A)\n ans += hit\n damage = hit * A\n damage_sum += damage\n q.append((x + 2 * D, damage))\n\nprint(ans)\n']
['Time Limit Exceeded', 'Accepted']
['s533755816', 's904742490']
[30852.0, 44540.0]
[2105.0, 1077.0]
[499, 547]
p02788
u994521204
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['import numpy as np\nn,d,a=map(int,input().split())\nflag=np.zeros(10**9+1)\nXH=[list(map(int,input().split())) for _ in range(n)]\nXH.sort(key=lambda A:A[0])\ncnt=0\nfor i in range(n):\n kaisu=0\n x,h=XH[i]\n if flag[x]==0:\n kaisu=(h+a-1)//a\n flag[x:min((x+2*d+1),10**9+1)]+=kaisu*a\n cnt+=kaisu\n else:\n if flag[x]<h:\n h-=flag[x]\n kaisu=(h+a-1)//a\n flag[x:min((x+2*d+1),10**9+1)]+=kaisu*a\n cnt+=kaisu\nprint(cnt)', 'from heapq import heappush, heappop\n\nn, d, a = map(int, input().split())\nactions = []\nfor _ in range(n):\n x, h = map(int, input().split())\n heappush(actions, (x, 0, (h + a - 1) // a))\ncnt = 0\nbomb = 0\ncurrent_bomb = 0\nwhile cnt < n:\n a, c, b = heappop(actions)\n if c:\n current_bomb -= b\n continue\n else:\n HP = b\n if HP <= current_bomb:\n cnt += 1\n continue\n else:\n HP -= current_bomb\n cnt += 1\n current_bomb += HP\n bomb += HP\n heappush(actions, (a + 2 * d, 1, HP))\nprint(bomb)\n']
['Runtime Error', 'Accepted']
['s900329579', 's798185631']
[12452.0, 35672.0]
[150.0, 1564.0]
[485, 603]
p02788
u994988729
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['N, D, A = map(int, input().split())\nXH = [list(map(int, input().split())) for _ in range(N)]\nXH.sort(key=lambda x: x[0])\ndamage = [0]*N\n\nans = 0\ni = 0\nwhile True:\n alive = True\n for j in range(i, N):\n x, h = XH[j]\n if h-damage[j] <= 0:\n continue\n i = j\n pos = x\n explode = (h + A - 1) // A\n break\n else:\n alive = False\n break\n\n if not alive:\n break\n\n for j in range(i, N):\n x, _ = XH[j]\n if x <= pos+2 * D:\n damage[j] += explode * A\n else:\n break\n ans += explode\n\nprint(ans)\n', 'import sys\nfrom collections import deque\ninput = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 7)\n\nN, D, A = map(int, input().split())\nXH = list(tuple(map(int, input().split())) for _ in range(N))\nXH.sort()\n\nans = 0\nmemo = deque()\ncnt = 0\nfor x, h in XH:\n while memo and memo[0][0] < x:\n _, i = memo.popleft()\n cnt -= i\n h -= cnt * A\n h = max(h, 0)\n bomb = (h + A - 1) // A\n ans += bomb\n cnt += bomb\n memo.append((x + 2 * D, bomb))\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s497405068', 's260100905']
[61684.0, 55748.0]
[2106.0, 794.0]
[610, 486]
p02788
u997641430
2,000
1,048,576
Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the _health_ of H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health. Silver Fox wins when all the monsters' healths become 0 or below. Find the minimum number of bombs needed to win.
['n, d, a = map(int, input().split())\nXH = [tuple(map(input().split())) for i in range(n)]\nXH.sort()\nX = [x for x, h in XH]\nH = [h for x, h in XH]\nX.append(10**10)\nH.append(0)\nj = 0\nS = [0]*(n+1)\nans = 0\nfor i in range(n):\n H[i] = max(0, H[i]-S[i])\n c = -(-H[i]//a)\n while X[j] <= X[i] + 2*d:\n j += 1\n S[i+1] += S[i] + a*c\n S[j] -= a*c\n ans += c\nprint(ans)\n', 'n, d, a = map(int, input().split())\nXH = []\nfor i in range(n):\n x, h = map(int, input().split())\n XH.append((x, h))\nXH.sort()\nX = [xh[0] for xh in XH]\nH = [xh[1] for xh in XH]\nX.append(10**10)\nH.append(0)\nj, c, s = 0, 0, 0\nfor i in range(n):\n H[i] -= s\n c += -(-H[i]//a)\n s = a*(-(-H[i]//a))\n while X[j] <= X[i]+2*d:\n j += 1\n H[j] += s\nprint(c)\n', 'n, d, a = map(int, input().split())\nXH = [tuple(map(int, input().split())) for i in range(n)]\nXH.sort()\nX = [x for x, h in XH]\nH = [h for x, h in XH]\nX.append(10**10)\nH.append(0)\nj = 0\nS = [0]*(n+1)\nans = 0\nfor i in range(n):\n H[i] = max(0, H[i]-S[i])\n c = -(-H[i]//a)\n while X[j] <= X[i] + 2*d:\n j += 1\n S[i+1] += S[i] + a*c\n S[j] -= a*c\n ans += c\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s848969207', 's884777655', 's072244003']
[3064.0, 40540.0, 44316.0]
[18.0, 1206.0, 1294.0]
[380, 373, 385]
p02790
u003505857
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a, b = map(int, input().split())\nc = []\nd = []\n\nfor i in range(1, a+1):\n c.append(b)\n\nfor j in range(1, b+1):\n d.append(a)\n\nif a > b:\n print(c)\nelse:\n print(d)', 'a, b = map(int, input().split())\n\nif a < b:\n print(str(a) * b)\nelse:\n print(str(b) * a)']
['Wrong Answer', 'Accepted']
['s907871095', 's450015931']
[9008.0, 9092.0]
[30.0, 26.0]
[171, 93]
p02790
u005318559
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b = input().split()\na = int(a)\nb = int(b)\nif(a==b):\n print("Yes")\nelse:\n print("No")', 'a,b = map(int, input().split())\nif(a==b):\n print("Yes")\nelse:\n print("No")', 'a, b = map.(int, input().split())\nif(a==b):\n print("Yes")\n else:\n\tprint("No")', 'a,b = input().split()\na = int(a)\nb = int(b)\nstring = ""\nif a>b:\n for i in range(a):\n string = string+str(b)\nelif b>a:\n for i in range(b):\n string = string+str(a)\nelse:\n for i in range(a):\n string = string+str(a)\nprint(string)']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s178088799', 's613339277', 's733434193', 's809266352']
[2940.0, 2940.0, 2940.0, 3064.0]
[17.0, 17.0, 18.0, 17.0]
[92, 76, 83, 256]
p02790
u007550226
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
["a,b = input().split()\naa=''.join([int(a) for _ in range(int(b))])\nbb=''.join([int(b) for _ in range(int(a))])\nprint(max(int(aa),int(bb)))\n ", "a,b = input().split()\naa=''.join([a for _ in range(int(b))])\nbb=''.join([b for _ in range(int(a))])\nprint(max(int(aa),int(bb)))"]
['Runtime Error', 'Accepted']
['s051347788', 's821759943']
[3060.0, 2940.0]
[17.0, 17.0]
[149, 127]
p02790
u010870870
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['i = list(map(int, input().split()))\nans=0\n\nif i[0]<i[1]:\n for n in range(i[1]):\n ans += i[0]*10**n\n print(ans)\n\nelse:\n for n in range(i[0]):\n ans += i[1]*10**n\n print(ans)\nprint(ans)', 'i = list(map(int, input().split()))\nans=0\n\nif i[0]<i[1]:\n for n in range(i[1]):\n ans += i[0]*10**n\n\nelse:\n for n in range(i[0]):\n ans += i[1]*10**n\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s368916084', 's777313987']
[2940.0, 3060.0]
[17.0, 18.0]
[216, 179]
p02790
u011062360
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a, b = map(int, input().split())\n\nans_a = 0\nans_b = 0\nans = []\nfor i in range(b):\n ans_a = ans_a + a*10**i\n\nfor i in range(a):\n ans_b = ans_b + b*10**i\n\nans_a = str(ans_a)\nans_b = str(ans_b)\n\nprint(ans_a,ans_b)\nprint(type(ans_a),type(ans_b))\n\nans = [ans_a,ans_b]\nprint(sorted(ans))\nanswer = ans[0]\nprint(answer)', 'a, b = map(int, input().split())\n\nans_a = 0\nans_b = 0\nans = []\nfor i in range(b):\n ans_a = ans_a + a*10**i\n\nfor i in range(a):\n ans_b = ans_b + b*10**i\n\nans_a = str(ans_a)\nans_b = str(ans_b)\n\nans = [ans_a,ans_b]\nanswer = sorted(ans)\nc = answer[0]\nprint(answer[0])']
['Wrong Answer', 'Accepted']
['s524107295', 's669192122']
[3064.0, 3064.0]
[18.0, 17.0]
[317, 269]
p02790
u018990794
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b = map(str, input().split())\n\nlis = []\nres_a = a\nres_b = b\n\nfor i in range(int(b)-1):\n res_a += a\nlis.append(res_a)\n\nfor i in range(int(a)-1):\n res_b += b\nlis.append(res_b)\n\nprint(int(sorted(lis)[0][0]))\n ', 'a,b = map(str, input().split())\n \nlis = []\nres_a = a\nres_b = b\n \nfor i in range(int(b)-1):\n res_a += a\nlis.append(res_a)\n \nfor i in range(int(a)-1):\n res_b += b\nlis.append(res_b)\n \nprint(int(sorted(lis)[0]))']
['Wrong Answer', 'Accepted']
['s638940338', 's452625810']
[3060.0, 3060.0]
[17.0, 17.0]
[211, 209]
p02790
u024450350
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a, b = map(int, input().split())\naStr = str()\nbStr = str()\n\nfor i in range(b + 1):\n aStr = aStr + str(a)\n\nfor i in range(a + 1):\n bStr = bStr + str(b)\n\nlst = list()\nlst.append(aStr)\nlst.append(bStr)\nlst.sort()\nprint(lst[0])\n', 'a, b = map(int, input().split())\naStr = str()\nbStr = str()\n\nfor i in range(b):\n aStr = aStr + str(a)\n\nfor i in range(a):\n bStr = bStr + str(b)\n\nif aStr > bStr:\n print(bStr)\nelse:\n print(aStr)\n']
['Wrong Answer', 'Accepted']
['s996664297', 's416354512']
[3060.0, 2940.0]
[17.0, 17.0]
[230, 204]
p02790
u027403702
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b = int(input().split())\nif "a" * b > "b" * a:\n print("b" * a)\nelse:\n print("a" * b)', 'a,b = input().split()\nif a * int(b) > b * int(a):\n print(b * int(a))\nelse:\n print(a * int(b))']
['Runtime Error', 'Accepted']
['s392437824', 's464827618']
[2940.0, 3060.0]
[17.0, 19.0]
[92, 99]
p02790
u032422971
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b = map(int,input().split())\nif a>b:\n print(str(b)*a)\n else:\n print(str(a)*b)', 'a,b = map(int, input().split())\nif a>b:\n print(str(b)*a)\nelse:\n print(str(a)*b)\n']
['Runtime Error', 'Accepted']
['s805043803', 's219900176']
[2940.0, 2940.0]
[18.0, 18.0]
[81, 86]
p02790
u034323841
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(int, input().split())\n\nif a<b :\n for i in range(b) :\n print(a)\nelse :\n for i in range(a) :\n print(b)', 'a,b=map(int, input().split())\n\nif a<b :\n print(str(a)*b)\nelse :\n print(str(b)*a)']
['Wrong Answer', 'Accepted']
['s130332167', 's791490894']
[9088.0, 9160.0]
[29.0, 24.0]
[128, 86]
p02790
u044138790
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a, b = (int(x) for x in input().split())\na = str(a)*b\nb = str(b)*a\nlis = [a, b]\nnew_lis = soted(lis)\nprint(new_lis[1])', 'a, b = (int(x) for x in input().split())\na1 = str(a)*b\nb1 = str(b)*a\nlis = [a1, b1]\nnew_lis = sorted(lis)\nprint(new_lis[0])\n']
['Runtime Error', 'Accepted']
['s117950217', 's207169588']
[2940.0, 2940.0]
[18.0, 17.0]
[118, 124]
p02790
u044964932
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['def main():\n a, b = input().split()\n A = a*int(a)\n B = b*int(b)\n ans = sorted([A, B])\n print(ans[0])\n\n\nif __name__ == "__main__":\n main()', 'def main():\n a, b = input().split()\n A = a*int(b)\n B = b*int(a)\n ans = sorted([A, B])\n print(ans[0])\n\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s934345402', 's972520582']
[2940.0, 2940.0]
[17.0, 17.0]
[155, 155]
p02790
u049182844
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a , b = map(int,input().split())\nprint(min( int( str(a) * b) , int( str(b) * a)))', 'a , b = map(int,input().split())\nprint(min(str(a) * b ,str(b) * a))']
['Wrong Answer', 'Accepted']
['s904593548', 's815486555']
[9020.0, 9064.0]
[24.0, 26.0]
[82, 68]
p02790
u051928503
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a, b=map(str, input().split())\nif int(a)<int(b):\n\tc=a\n a=b\n b=c\nprint(b*int(a))', 'a, b=map(str, input().split())\nif int(a)<int(b):\n\tc=a\n\ta=b\n\tb=c\nprint(b*int(a))']
['Runtime Error', 'Accepted']
['s014316162', 's090472277']
[2940.0, 2940.0]
[17.0, 17.0]
[85, 79]
p02790
u056659569
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(int,input().split())\nif a>b:\n print("b"*a)\nelif b>a:\n print("a"*b)\nelse:\n print("a"*b)\n ', 'a,b=map(int,input().split())\nif a>b:\n print(str(b)*a)\nelif b>a:\n print(str(a)*b)\nelse:\n print(str(a)*b)']
['Wrong Answer', 'Accepted']
['s972786732', 's341154702']
[2940.0, 2940.0]
[17.0, 17.0]
[99, 106]
p02790
u064563749
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(int,input().split())\nmin(str(a)*b,str(b)*a)', 'a,b=map(int,input().split())\nmin(str(a)*b,str(b)*a)', 'a,b=map(int,input().split())\nprint(min(str(a)*b,str(b)*a))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s409931389', 's603675758', 's267464583']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[51, 51, 58]
p02790
u067694718
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a, b = [i for i in input().split()]\nprint(max(int(a * int(b)), int(b * int(a)))', 'a, b = [i for i in input().split()]\nprint(max(int(a * int(b)), int(b * int(a))))']
['Runtime Error', 'Accepted']
['s075076572', 's053489078']
[2940.0, 2940.0]
[17.0, 17.0]
[79, 80]
p02790
u072606168
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a = list(map(str, input().split()))\na.sort()\nprint(a[0])', 'a = list(map(str, input().split()))\na[0],a[1] = a[0]*int(a[1]),a[1]*int(a[0])\na.sort()\nprint(a[0])']
['Wrong Answer', 'Accepted']
['s638017779', 's224233455']
[3060.0, 2940.0]
[19.0, 17.0]
[56, 98]
p02790
u081340269
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['# B\na, b = map(int, input().split())\n\na2 = int(str(a)*b)\nb2 = int(str(b)*a)\n\nif a2<b2:\n print(a2)\nelse:\n print(b2)', '# B\na, b = map(int, input().split())\n\na2 = str(a)*b\nb2 = str(b)*a\n\nif a<b:\n print(a2)\nelse:\n print(b2)']
['Wrong Answer', 'Accepted']
['s748841844', 's505287868']
[2940.0, 2940.0]
[17.0, 17.0]
[116, 104]
p02790
u082601076
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b = map(str,input().split())\nprint(min(int(a*int(b)),int(int(a)*b)))', 'a,b = map(int,input().split())\nprint(str(min(a,b))*max(a,b))\n']
['Wrong Answer', 'Accepted']
['s961320593', 's789359239']
[2940.0, 2940.0]
[17.0, 17.0]
[70, 61]
p02790
u082861480
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b = map(int,input().split())\nprint(str(a)*b if a > b else str(b)*a)\n', 'a,b = map(int,input().split())\nprint(str(a)*b if a < b else str(b)*a)']
['Wrong Answer', 'Accepted']
['s040800461', 's478414382']
[2940.0, 2940.0]
[17.0, 17.0]
[70, 69]
p02790
u084320347
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b = list(input().split())\nprint(min(a*int(b), b*int(a))', "a,b=map(int,input().stlip())\n\nx=''\n\nfor i in range(a):\n x += str(b)\n \ny=''\n\nfor i in range(b):\n y += str(a)\n \nprint(min(x,y))\n \n", 'a,b = list(input().split())\nprint(min(a*int(b), b*int(a)))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s005588476', 's024710896', 's171557469']
[2940.0, 3064.0, 2940.0]
[17.0, 17.0, 17.0]
[57, 132, 58]
p02790
u086503932
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(int,open(0));print(str(min(a,b))*max(a,b))\n', 'a,b = map(int, input().split())\nprint(str(min(a,b))*max(a,b))']
['Runtime Error', 'Accepted']
['s128681478', 's527440111']
[2940.0, 2940.0]
[17.0, 17.0]
[51, 61]
p02790
u089230684
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['n = list(map(int,input().split()))\na = n[0]\nb = n[1]\ntmp = 0\nif a < b:\n for i in range (a):\n tmp += b * (10 ** i)\n print (tmp)\nelse:\n for i in range (b):\n tmp += a * (10 ** i)\n print (tmp)', 'n,m=map(int,input().split())\nmn = min(m,n)\nmx = max(m,n)\nprint(str(mn)*mx)']
['Wrong Answer', 'Accepted']
['s232061226', 's887116909']
[3060.0, 9164.0]
[17.0, 23.0]
[214, 74]
p02790
u091217940
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(int,input().split())\nA=str(a)*b\nB=str(b)*a\nl=[A,B]\nprint(l)\nl.sort()\nprint(l)', 'a,b=map(int,input().split())\nA=str(a)*b\nB=str(b)*a\nl=[A,B]\n\nl.sort()\n\nprint(l[0])']
['Wrong Answer', 'Accepted']
['s582879932', 's893105207']
[2940.0, 2940.0]
[17.0, 17.0]
[85, 81]
p02790
u092278825
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b = map(int, input().split())\nans = 0\nif a>=b:\n for i in range(a):\n ans += b*(10**a)\n print(ans)\nelse:\n for j in range(b):\n ans += a*(10**b)\n print(ans)\n \n', 'a,b = map(int, input().split())\nans = 0\nif b>=a:\n for i in range(b):\n ans += a*(10**i)\n print(ans)\nelse:\n for j in range(a):\n ans += b*(10**j)\n print(ans)\n ']
['Wrong Answer', 'Accepted']
['s733187185', 's478734736']
[2940.0, 2940.0]
[17.0, 17.0]
[168, 167]
p02790
u093683571
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(int,input().split())\nif a>b:\n print(int(str(a)*b))\nelif a<b:\n print(int(str(b)*a))\nelse:\n print(int(str(a)*b))', 'a,b=map(int,input().split())\nif a>b:\n print(str(a)*b)\nelif a<b:\n print(str(b)*a)\nelse:\n print(str(a)*b)', 'a,b=map(int,input().split())\nif a>b:\n print(int(str(b)*a))\nelif a<b:\n print(int(str(a)*b))\nelse:\n print(int(str(a)*b))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s052095459', 's499256618', 's599380903']
[2940.0, 2940.0, 3060.0]
[17.0, 17.0, 18.0]
[121, 106, 121]
p02790
u094102716
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a = list(map(int,input().split()))\nb = a[0] - a[1]\nif b == 0 :\n\tprint(str(a[0]) * a[0])\nelse : print(str(max(a[0], a[1])) * min(a[0], a[1]))', 'a = list(map(int,input().split()))\nb = a[0] - a[1]\nif b == 0 :\n\tprint(str(a[0]) * a[0])\nelse : print(str(min(a[0], a[1])) * max(a[0], a[1]))']
['Wrong Answer', 'Accepted']
['s617040210', 's114989031']
[3060.0, 3060.0]
[18.0, 18.0]
[140, 140]
p02790
u098679988
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a, b = map(int, input().split())\n\nans1 = ""\nans2 = ""\nfor i in range(b):\n ans1.append(a)\n\nfor i in range(a):\n ans2.append(b)\n \nprint(ans1, ans2)', 'a, b = map(int, input().split())\n\nans1 = ""\nans2 = ""\nfor i in range(b):\n ans1 = ans1 + str(a)\n\nfor i in range(a):\n ans2= ans2 + str(b)\n \nlist = []\nlist.append(ans1)\nlist.append(ans2)\n\nlist.sort()\n\nprint(list[0])']
['Runtime Error', 'Accepted']
['s858189410', 's192123527']
[2940.0, 3060.0]
[17.0, 18.0]
[147, 215]
p02790
u104005543
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a, b = map(int, input().split())\nx, y = 0, 0\nfor i in range(b):\n x += a * (10 ** (b - 1))\nfor i in range(a):\n y =+ b * (10 ** (a - 1))\nif a <= b:\n print(x)\nelse:\n print(y)', 'a, b = map(int, input().split())\nx, y = 0, 0\nfor i in range(b):\n x += a * (10 ** (b - 1))\nfor i in range(a):\n y += b * (10 ** (a - 1))\nif a <= b:\n print(x)\nelse:\n print(y)', 'a, b = map(int, input().split())\nx, y = 0, 0\nfor i in range(b):\n x += a * (10 ** i)\nfor i in range(a):\n y += b * (10 ** i)\nif a <= b:\n print(x)\nelse:\n print(y)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s587699710', 's982915620', 's994389940']
[2940.0, 3060.0, 2940.0]
[17.0, 19.0, 18.0]
[183, 183, 171]
p02790
u106778233
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(int,input().split())\nc=0\nfor i in range(a):\n c+=b*(10**i)\n\nd=0\nfor j in range(b):\n d+=a*(10**j)\n\ne=min(c,d)\nprint(e)', 'a,b=map(int,input().split())\nc=0\n\nfor i in range(a):\n c+=b*(10**i)\n\nd=0\nfor j in range(b):\n d+=a*(10**j)\n\ne=c if b<a else d\nprint(e)\n']
['Wrong Answer', 'Accepted']
['s030557691', 's882560832']
[2940.0, 2940.0]
[17.0, 18.0]
[126, 135]
p02790
u109133010
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(int,input().split())\nif a>=b:\n print(str(a)*b)\nelse:\n print(str(b)*a)', 'a,b=map(int,input().split())\nif a>=b:\n print(str(b)*a)\nelse:\n print(str(a)*b)']
['Wrong Answer', 'Accepted']
['s196263779', 's913677662']
[2940.0, 2940.0]
[17.0, 17.0]
[83, 83]
p02790
u112364985
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(int,input().split())\nA=str(a)\nB=str(b)\nnum_1=int(A*b)\nnum_2=int(B*a)\nif num_1>num_2:\n print(num_2)\nelif num_1<num_2:\n print(num_1)\nelif num_1==num_2:\n print(num_1)', 'a,b=map(int,input().split())\nA=str(a)\nB=str(b)\nnum_1=int(A*b)\nnum_2=int(B*a)\nif num_1>=num_2:\n print(num_2)\nelif num_1<num_2:\n print(num_1)\n', 'a,b=input().split()\nnum_a=int(a*int(b))\nnum_b=int(b*int(a))\n\nif num_a>num_b:\n print(num_a)\nelif num_a<num_b:\n print(num_b)\nelse:\n print(num_a)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s479941105', 's538054590', 's130796318']
[3060.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0]
[174, 142, 151]
p02790
u113255362
2,000
1,048,576
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?
['a,b=map(str,input().split())\nres = ""\nif a < b:\n for i in range(b):\n res += a\nelse:\n for i in range(a):\n res += b\nprint(res)', 'a,b=map(str,input().split())\nres = ""\nif a < b:\n for i in range(int(b)):\n res += a\nelse:\n for i in range(int(a)):\n res += b\nprint(res)']
['Runtime Error', 'Accepted']
['s486342101', 's389351947']
[8808.0, 8976.0]
[20.0, 25.0]
[130, 142]