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
p03290
u506549878
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['n, s = map(int, input().split())\ndata = []\nfor i in range(1,n+1):\n k, v = map(int, input().split())\n for j in range(1,k+1):\n if j<k:\n data.append([j,j*i*100])\n else:\n data.append([j,j*i*100+v])\nm = len(data)\nkekka = {}\nfor i in range(2 ** m):\n bag = []\n prob = []\n \n for j in range(m): \n if ((i >> j) & 1): \n bag.append(data[j][1]) \n prob.append(data[j][0])\n if sum(bag) >= s:\n kekka[sum(prob)] = sum(bag)\nmin(kekka.items(), key = lambda x:x[1])[0] ', "D,G=map(int,input().split())\n \npc=[list(map(int,input().split())) for i in range(D)]\n \nans=float('inf')\n \nfor i in range(1<<D):\n s=0\n c=0\n for k in range(D):\n if 1&i>>k:\n s+=(k+1)*100*pc[k][0]+pc[k][1]\n c+=pc[k][0]\n \n if s>=G:\n ans=min(ans,c)\n \n if s<G:\n for k in reversed(range(D)):\n if not(1&i>>k):\n ac=-(-(G-s)//((k+1)*100))\n if pc[k][0]>ac:\n ans=min(ans,c+ac)\n break\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s354247730', 's339921300']
[3188.0, 3064.0]
[2104.0, 25.0]
[721, 519]
p03290
u514401521
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = map(int, input().split())\nP = []\nC = []\nans = 10 ** 10\nfor i in range(D):\n p, c = map(int, input().split())\n P.append(p)\n C.append(c)\n\nfor i in range(2 ** D):\n a = 0\n b = 0\n for j in range(D):\n if i >> j & 1 :\n a += 100 * P[j] * (j + 1) + C[j]\n b += P[j]\n for k in range(D - 1, -1, -1):\n if (i >> k) & 1:\n continue\n if b >= G:\n break\n for l in range(P[k]):\n a += 100 * (k + 1)\n b += 1\n if a >= G:\n break\n ans = min(ans, b)\nprint(ans)', 'D, G = map(int, input().split())\nP = []\nC = []\nans = 10 ** 10\nfor i in range(D):\n p, c = map(int, input().split())\n P.append(p)\n C.append(c)\n\nfor i in range(2 ** D):\n a = 0\n b = 0\n for j in range(D):\n if (i >> j) & 1 :\n a += 100 * P[j] * (j + 1) + C[j]\n b += P[j]\n for k in range(D - 1, -1, -1):\n if (i >> k) & 1:\n continue\n if b >= G:\n break\n for l in range(P[k] + 1):\n a += 100 * (k + 1)\n b += 1\n if a >= G:\n break\n ans = min(ans, b)\nprint(ans)', 'D, G = map(int, input().split())\nP = []\nC = []\nans = 10 ** 10\nfor i in range(D):\n p, c = map(int, input().split())\n P.append(p)\n C.append(c)\n\nfor i in range(2 ** D):\n a = 0\n b = 0\n for j in range(D):\n if i >> j & 1 :\n a += 100 * P[j] * (j + 1) + C[j]\n b += P[j]\n for k in range(D - 1, -1, -1):\n if (i >> k) & 1:\n continue\n if b >= G:\n break\n for l in range(P[k] + 1):\n a += 100 * (k + 1)\n b += 1\n if a >= G:\n break\n ans = min(ans, b)\nprint(ans)', 'd, g = map(int, input().split())\np = []\nc = []\n\nfor i in range(d):\n _p, _c = map(int, input().split())\n p.append(_p)\n c.append(_c)\ncnt = 10 ** 5\nfor i in range(2**d):\n tmp = 0\n ans = 0\n for j in range(d):\n if i >> j & 1:\n tmp += p[j]\n ans += c[j] + p[j] * 100 * (j + 1)\n for j in range(d-1, -1, -1):\n if ans >= g:\n break\n if i >> j & 1:\n continue\n for k in range(p[j] - 1):\n ans += 100 * (j + 1)\n tmp += 1\n if ans >= g:\n break\n if ans >= g:\n cnt = min (tmp, cnt)\nprint(cnt)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s495789245', 's597539494', 's616343128', 's957346083']
[3064.0, 3064.0, 3064.0, 3064.0]
[140.0, 155.0, 152.0, 167.0]
[588, 594, 592, 625]
p03290
u516566941
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = map(int,input().split())\nP=[]\nC=[]\nfor _ in range(D):\n p,c = map(int,input().split())\n P.append(p)\n C.append(c)\nanss=2**10\nfor i in range(1 << D):\n ans = 0\n summ = 0\n nokori = set(range(1,D+1))\n for j in range(D):\n if 1 & (i >> j):\n summ += P[j]*100*(j+1)+C[j]\n ans += P[j]\n nokori.discard(j+1)\n if summ < G:\n use = max(nokori)\n n = min(P[use-1],-((G-summ)//(100*use)))\n ans += n\n summ += n* use* 100\n\n if summ < G:\n summ+=C[use-1]\n\n if summ >= G:\n anss =min(ans,anss)\n \nprint(anss', 'd,g = map(int,input().split())\npc = [list(map(int,input().split())) for i in range(d)]\n\nans = float("inf")\n\n\nfor bit in range(1<<d):\n count = 0\n sum = 0\n nokori = set(range(1,d+1))\n\n for i in range(d):\n if bit & (1<<i):\n sum +=pc[i][0]*(i+1)*100+pc[i][1]\n count +=pc[i][0]\n nokori.discard(i+1)\n\n\n\n if sum < g:\n use = max(nokori)\n n = min(pc[use-1][0],-(-(g-sum)//(use*100)))\n count += n\n sum += n*use *100\n\n if sum >= g:\n ans = min(ans,count)\nprint(ans)']
['Runtime Error', 'Accepted']
['s535119213', 's707093315']
[3064.0, 3064.0]
[18.0, 25.0]
[606, 546]
p03290
u522140891
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["def main():\n D, G = list(map(int, input().split()))\n P = []\n for i in range(1, D+1):\n P.append(tuple(map(int, input().split())))\n\n # print(D, G, P)\n minp = float('inf')\n for bit in range(1 << D):\n total = 0\n num_p = 0\n bset = set()\n for i in range(D):\n mask = 1 << i\n if bit & mask:\n total += P[i][1] + 100*(i+1)*P[i][0]\n num_p += P[i][0]\n bset.add(i)\n\n # print(f'bset:{bset}, num_p:{num_p}')\n\n res = G - total\n if res <= 0:\n if num_p < minp:\n minp = num_p\n continue\n\n for i in reversed(sorted(set([i for i in range(D)]) - bset)):\n maxv = 100*(i+1) * (P[i][0]-1)\n\n if res <= maxv:\n num_take = max(min(bisect.bisect(list(range(0, maxv+100*(i+1), 100*(i+1))), res)-1, P[i][0]-1), 1)\n # print(i, list(range(0, maxv, 100*(i+1))))\n # print(f'res:{res} so solve {100*(i+1)} * {num_take}')\n num_p += num_take\n res -= 100*(i+1)*num_take\n if num_p < minp:\n minp = num_p\n break\n\n res -= maxv\n # print(f'solve {i+1} * {P[i][0]-1}')\n num_p += (P[i][0]-1)\n\n print(minp)\n\n\nif(__name__ == '__main__'):\n main()", "def main():\n D, G = list(map(int, input().split()))\n P = []\n for i in range(1, D+1):\n P.append(tuple(map(int, input().split())))\n\n # print(D, G, P)\n minp = float('inf')\n for bit in range(1 << D):\n total = 0\n num_p = 0\n bset = set()\n for i in range(D):\n mask = 1 << i\n if bit & mask:\n total += P[i][1] + 100*(i+1)*P[i][0]\n num_p += P[i][0]\n bset.add(i)\n\n # print(f'bset:{bset}, num_p:{num_p}')\n\n res = G - total\n if res <= 0:\n if num_p < minp:\n minp = num_p\n continue\n\n for i in reversed(sorted(set([i for i in range(D)]) - bset)):\n maxv = 100*(i+1) * (P[i][0]-1)\n\n if res <= maxv:\n num_take = max(min(bisect.bisect(list(range(0, maxv+100*(i+1), 100*(i+1))), res)-1, P[i][0]-1), 1)\n # print(i, list(range(0, maxv, 100*(i+1))))\n # print(f'res:{res} so solve {100*(i+1)} * {num_take}')\n num_p += num_take\n res -= 100*(i+1)*num_take\n if num_p < minp:\n minp = num_p\n break\n\n res -= maxv\n # print(f'solve {i+1} * {P[i][0]-1}')\n num_p += (P[i][0]-1)\n\n print(minp)\n\n\nif(__name__ == '__main__'):\n main()", "import bisect\n\n\ndef main():\n D, G = list(map(int, input().split()))\n P = []\n for i in range(1, D+1):\n P.append(tuple(map(int, input().split())))\n\n # print(D, G, P)\n minp = float('inf')\n for bit in range(1 << D):\n total = 0\n num_p = 0\n bset = set()\n for i in range(D):\n mask = 1 << i\n if bit & mask:\n total += P[i][1] + 100*(i+1)*P[i][0]\n num_p += P[i][0]\n bset.add(i)\n\n # print(f'bset:{bset}, num_p:{num_p}')\n\n res = G - total\n if res <= 0:\n if num_p < minp:\n minp = num_p\n continue\n\n for i in reversed(sorted(set([i for i in range(D)]) - bset)):\n maxv = 100*(i+1) * (P[i][0]-1)\n\n if res <= maxv:\n num_take = max(min(bisect.bisect(list(range(0, maxv+100*(i+1), 100*(i+1))), res)-1, P[i][0]-1), 1)\n # print(i, list(range(0, maxv, 100*(i+1))))\n # print(f'res:{res} so solve {100*(i+1)} * {num_take}')\n num_p += num_take\n res -= 100*(i+1)*num_take\n if num_p < minp:\n minp = num_p\n break\n\n res -= maxv\n # print(f'solve {i+1} * {P[i][0]-1}')\n num_p += (P[i][0]-1)\n\n print(minp)\n\n\nif(__name__ == '__main__'):\n main()"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s577967158', 's669475018', 's644985657']
[9168.0, 9308.0, 9300.0]
[37.0, 33.0, 41.0]
[1160, 1160, 1176]
p03290
u531220228
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G, *pc = map(int, open(0).read().split())\npc = list(zip(*[iter(pc)]*2))\n\n\n\ntotal_points = []\nfor i in range(D):\n total_points.append(pc[i][0] * (i+1) * 100 + pc[i][1])\n \nans_list = [i[0] for i, x in zip(pc, total_points) if x >= G]\n\n\nefficient_order = sorted(list(zip([x/y for x,(y,z) in list(zip(total_points, pc))], range(1, D+1))), reverse = True)\n\nachieved = False\nremained = G\nhighest_p = D\n\nans_other = 0\n\nfor _, i in efficient_order:\n if remained <= 0:\n break\n elif math.ceil(remained / (i * 100)) <= pc[i - 1][0]:\n ans_other += math.ceil(remained / (i * 100))\n remained -= (math.ceil(remained / (i * 100)) * i * 100)\n else:\n ans_other += pc[i - 1][0]\n remained -= (i * 100 * pc[i - 1][0] + pc[i - 1][1])\n\nans_list.append(ans_other)\n\nprint(min(ans_list))', "import numpy as np\n\nD, G, *pc = map(int, open(0).read().split())\npc = list(zip(*[iter(pc)]*2))\np, c = np.array([]), np.array([])\nfor (x,y) in pc:\n p = np.append(p, x)\n c = np.append(c, y)\n \nimport numpy as np\nimport math\n\nbase_points = np.array([i*100 for i in range(1, D+1)])\n\nans = []\n\nfor i in range(2**D):\n bit_flag = np.array(list(map(int, format(i, '0%db' %D))))\n points = sum(bit_flag * (c + p*base_points))\n solved_num = sum(bit_flag * p)\n \n if points >= G:\n ans.append(solved_num)\n\n else:\n remained = G - points\n remained_problems = sorted((bit_flag==False) * np.array(range(1, D+1)), reverse=True)\n i = 0\n\n while True:\n if remained <= 0:\n break\n \n highest_p = remained_problems[i]\n\n if math.ceil(remained / (highest_p * 100)) <= p[highest_p - 1]:\n solved_num += math.ceil(remained / (highest_p * 100))\n remained -= (math.ceil(remained / (highest_p * 100)) * highest_p * 100)\n else:\n solved_num += p[highest_p - 1]\n remained -= (highest_p * 100 * p[highest_p - 1] + c[highest_p - 1])\n i += 1\n\n ans.append(solved_num)\n \nprint(int(min(ans)))"]
['Runtime Error', 'Accepted']
['s653991309', 's445157560']
[9080.0, 27276.0]
[23.0, 162.0]
[967, 1273]
p03290
u548303713
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['# ABC104-C\n\nD,G=map(int,input().split()) \nbox=[] \nfor i in range(D): \n box.append(list(map(int,input().split()))) \nbox.insert(0,[0,0]) \ninfo=[[0,0] for i in range(2**D)] \n\nfor i in range(2*D): \n for j in range(1,D+1): \n if (i>>(j-1))&1: \n info[i][0]+=box[j][1]+j*100*box[j][0] \n info[i][1]+=box[j][0] \n info2[i][j]=box[j][0] \n\nfor i in range(2**D):\n score=G-info[i][0]\n if score<=0:\n continue\n else:\n n=D\n while score>0:\n #print(str(i)+":"+str(score))\n if (i>>(n-1))&1:\n continue\n else:\n for j in range(1,box[n][0]+1):\n score -= 100*n\n info[i][1]+=1 \n if j==box[n][0]: \n score-=box[n][1]\n if score<=0:\n break\n n-=1\n \nl=len(info)\nfor i in range(l-1):\n min=info[i][1]\n m=info[i]\n t=i\n for j in range(i+1,l):\n if min>info[j][1]:\n min=info[j][1]\n t=j\n info[i]=info[t]\n info[t]=m\nprint(info[0][1])', 'D,G=map(int,input().split()) \nbox=[] \nfor i in range(D): \n box.append(list(map(int,input().split()))) \nbox.insert(0,[0,0]) \ninfo=[[0,0] for i in range(2**D)] \ninfo2=[[0]*(D+1) for i in range(2**D)] \n\nfor i in range(2**D): \n for j in range(1,D+1): \n if (i>>(j-1))&1: \n info[i][0]+=box[j][1]+j*100*box[j][0] \n info[i][1]+=box[j][0] \n info2[i][j]=box[j][0] \n\nfor i in range(2**D):\n score=G-info[i][0]\n if score<=0:\n continue\n else:\n n=D\n while score>0:\n num=box[n][0]-info2[i][n] \n #print(num)\n #print(str(i)+":"+str(score))\n if num!=0:\n for j in range(1,num+1):\n score -= 100*n\n info[i][1]+=1 \n if j==num: \n score-=box[n][1]\n if score<=0:\n break\n n-=1\n \nl=len(info)\nfor i in range(l-1):\n min=info[i][1]\n m=info[i]\n t=i\n for j in range(i+1,l):\n if min>info[j][1]:\n min=info[j][1]\n t=j\n info[i]=info[t]\n info[t]=m\nprint(info[0][1])']
['Runtime Error', 'Accepted']
['s705673997', 's800338229']
[3188.0, 3316.0]
[20.0, 223.0]
[1374, 1462]
p03290
u548684908
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = list(map(int,input().split()))\npoint_list = []\nfor _ in range(D):\n point_list.append(input())\nprint(point_list)', "D,G = list(map(int,input().split()))\nPC = [list(map(int, input().split())) for _ in range(D)]\n\ndef all_green(t,s):\n if t == -1:\n return float('inf')\n num = min(PC[t][0],s//(100*(t+1)))\n k = num * 100 * (t+1)\n if num == PC[t][0]:\n k += PC[t][1]\n if k < s:\n num += all_green(t-1,s-k)\n return min(num,all_green(t-1,s))\nprint(all_green(D-1,G))"]
['Wrong Answer', 'Accepted']
['s703988097', 's442124884']
[2940.0, 3064.0]
[17.0, 19.0]
[120, 378]
p03290
u552192779
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["d,g = map(int,input().split())\nprobs = []\nans = float('inf')\nfor i in range(d):\n p,c =map(int,input().split())\n probs.append(((i+1)*100,p,c))\n\nfor i in range(2**d):\n count = 0\n score = 0\n yet = []\n for j in range(d):\n if ((i >>j) & 1):\n count +=probs[j][1]\n score +=probs[j][2] +probs[j][0]*probs[j][1]\n else:\n yet.append((probs[j][0],probs[j][1]-1))\n if ans <= count:\n continue\n elif score>=g:\n ans = count\n continue\n yet.sort(reverse=True)\n if score+sum([x*y for x,y in yet]) <g:\n continue\n for point,num in yet:\n solve = min((g - score-0.1)//point +1,num)\n count += solve\n score += solve*point\n if count >= ans:\n break\n if score >=g:\n ans = count\nprint(ans)\n \n \n \n ", "d,g = map(int,input().split())\nprobs = []\nans = float('inf')\nfor i in range(d):\n p,c =map(int,input().split())\n probs.append(((i+1)*100,p,c))\n\nfor i in range(2**d):\n count = 0\n score = 0\n yet = []\n for j in range(d):\n if ((i >>j) & 1):\n count +=probs[j][1]\n score +=probs[j][2] +probs[j][0]*probs[j][1]\n else:\n yet.append((probs[j][0],probs[j][1]-1))\n if ans <= count:\n continue\n elif score>=g:\n ans = count\n continue\n yet.sort(reverse=True)\n if score+sum([x*y for x,y in yet]) <g:\n continue\n for point,num in yet:\n solve = min((g - score-0.1)//point +1,num)\n count += solve\n score += solve*point\n if count >= ans:\n break\n if score >=g:\n ans = count\n break\n \nprint(int(ans))\n \n \n \n "]
['Wrong Answer', 'Accepted']
['s930909351', 's838549614']
[3064.0, 3064.0]
[27.0, 26.0]
[853, 881]
p03290
u556799364
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["# -*- coding: utf-8 -*-\nD, G = map(int, input().split(' '))\np_c_pairs = [((i+1) * 100, list(map(int, input().split(' ')))) for i in range(D)]\n\nimport math\nans = float('inf')\np_c_pairs.sort(key=lambda x: -x[0])\nfor d in range((D+1)**2):\n print(bin(d))\n\n cnt = 0\n g = G\n for i in range(D):\n if 1 & (d >> i):\n score, (p, c) = p_c_pairs[i]\n g -= score * p + c\n cnt += p\n\n if g > 0:\n for i in range(D):\n if not (1 & (d >> i)):\n score, (p, c) = p_c_pairs[i]\n n = min(p, int(math.ceil(g/score)))\n g -= score * n\n cnt += n\n break\n\n # print(bin(d), g)\n if g <= 0:\n ans = min(ans, cnt)\n\nprint(ans)", "# -*- coding: utf-8 -*-\nD, G = map(int, input().split(' '))\np_c_pairs = [((i+1) * 100, list(map(int, input().split(' ')))) for i in range(D)]\n\nimport math\nans = float('inf')\np_c_pairs.sort(key=lambda x: -x[0])\nfor d in range(1<<D):\n # print(bin(d))\n\n cnt = 0\n g = G\n for i in range(D):\n if 1 & (d >> i):\n score, (p, c) = p_c_pairs[i]\n g -= score * p + c\n cnt += p\n\n if g > 0:\n for i in range(D):\n if not (1 & (d >> i)):\n score, (p, c) = p_c_pairs[i]\n n = min(p, int(math.ceil(g/score)))\n g -= score * n\n cnt += n\n break\n\n # print(bin(d), g)\n if g <= 0:\n ans = min(ans, cnt)\n\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s129573547', 's850999768']
[9240.0, 9144.0]
[30.0, 34.0]
[748, 746]
p03290
u557494880
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = map(int,input().split())\nP = []\nC = []\nfor i in range(D):\n p, c = map(int,input().split())\n P.append(p)\n C.append(C)\n s += p\n\n\ndp = [[0 for in range(s+1)] for j in range(D+1)]\nfor i in range(D):\n p = P[i]\n c = C[i]\n t = 100*i\n for j in range(s+1):\n for k in range(p+1):\n if k = p:\n if j >= k:\n dp[i+1][j] = max(dp[i+1][j],dp[i][j-k]+c)\n else:\n if j >= k:\n d[i+1][j] = max(dp[i][j-k]+t*k,dp[i+1][j])\n else:\n break\nfor i in range(s+1):\n if d[N][i] >= G:\n ans = i\nprint(ans)\n \n ', 'D,G = map(int,input().split())\nP = [0]*D\nC = [0]*D\nfor i in range(D):\n P[i], C[i] = map(int,input().split())\ns = sum(P)\n\n\ndp = [[0 for i in range(s+1)] for j in range(D+1)]\nfor i in range(D):\n p = P[i]\n c = C[i]\n t = 100*(i+1)\n for j in range(s+1):\n for k in range(p+1):\n if k == p:\n if j >= k:\n dp[i+1][j] = max(dp[i+1][j],dp[i][j-k]+c+t*k)\n else:\n if j >= k:\n dp[i+1][j] = max(dp[i][j-k]+t*k,dp[i+1][j])\n else:\n break\nfor i in range(s+1):\n if dp[D][i] >= G:\n ans = i\n break\nprint(ans)']
['Runtime Error', 'Accepted']
['s825265139', 's506648809']
[2940.0, 3316.0]
[17.0, 725.0]
[727, 709]
p03290
u557792847
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import sys\nimport numpy as np\nimport math\n# for AtCoder\n# import fractions\nfrom collections import deque \nfrom functools import reduce\n\n# input = sys.stdin.readline\n\nd, g = map(int, input().split())\np = [list(map(int, input().split())) for x in range(d)]\nfor i in range(d):\n ex = ((i+1) * 100 * p[i][0] + p[i][1]) / p[i][0]\n p[i].append(ex)\n p[i].append((i+1)*100)\np.sort(key=lambda x : x[3], reverse=True)\ncnt = 0\npoint = 0\ntotal = 0\nfor i in range(d):\n i_total = p[i][0] * p[i][3] + p[i][1]\n cnt_c = p[i][0]\n \n point_h = 0\n point_h_idx = i\n for j in range(i, d):\n if p[j][3] > point_h:\n point_h = p[j][3]\n point_h_idx = j\n cnt_c2 = ((g - total) + (p[j][3] - 1)) // p[j][3]\n if cnt_c2 > p[j][0]:\n cnt_c2 = p[j][0]\n \n if cnt_c2 * p[j][3] + total >= g:\n cnt += cnt_c2\n break\n cnt += p[i][0]\n total += i_total\n if (total >= g):\n break\nprint(cnt)\n\n\n\n\n\n\n', 'import sys\nimport numpy as np\nimport math\nimport collections\nimport copy\nfrom collections import deque \nfrom functools import reduce\nfrom itertools import product\n\n# input = sys.stdin.readline\n\nD, G = map(int, input().split())\npc = [list(map(int, input().split())) for _ in range(D)]\nans = 10**8\nfor p in product((0, 1), repeat=D):\n nmax = -1\n num = 0\n total = 0\n need = 0\n for i, pi in enumerate(p):\n if pi == 1:\n num += pc[i][0]\n total += pc[i][0]*(i+1)*100 + pc[i][1]\n else:\n nmax = i\n# print(p)\n\n if total < G:\n if nmax < 0:\n continue\n if total + nmax * 100 * pc[nmax][0] + pc[nmax][1] < G:\n continue\n need = math.ceil((G-total) / ((nmax+1)*100))\n ans = min(ans, num+need)\n# print(nmax, num, total, need, ans)\n\nprint(ans)\n\n\n\n']
['Wrong Answer', 'Accepted']
['s520585005', 's135387043']
[27036.0, 27256.0]
[119.0, 117.0]
[1066, 877]
p03290
u566428756
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d,g=map(int,input().split())\npc={_:(list(map(int,input().split()))) for _ in range(d)}\nbin_lst=[]\nd2=2**d\nfor x in range(d2):\n buf=bin(x)[2:]\n len_buf=len(buf)\n if len_buf<d:\n buf=\'0\'*(d-len_buf)+buf\n bin_lst.append(buf)\nprint(bin_lst)\nlst_cnt=[]\nbuf_lst=[]\nfor x in bin_lst:\n cnt=0\n buf_int=0\n len_x=len(x)\n for y in range(d):\n if x[y]=="1":\n buf_lst=pc[y]\n buf_int+=(y+1)*100*buf_lst[0]+buf_lst[1]\n cnt+=buf_lst[0]\n if buf_int<g:\n buf_index=x.rfind("0")\n buf_lst=pc[buf_index]\n i=buf_lst[0]\n for z in range(1,i):\n if buf_int+(buf_index+1)*100*z>=g:\n buf_int+=(buf_index+1)*100*z\n cnt+=z\n break\n if buf_int>=g:\n lst_cnt.append(cnt)\nprint(min(lst_cnt))', 'd,g=map(int,input().split())\npc={_:(list(map(int,input().split()))) for _ in range(d)}\nbin_lst=[]\nd2=2**d\nfor x in range(d2):\n buf=bin(x)[2:]\n len_buf=len(buf)\n if len_buf<d:\n buf=\'0\'*(d-len_buf)+buf\n bin_lst.append(buf)\nlst_cnt=[]\nbuf_lst=[]\nfor x in bin_lst:\n cnt=0\n buf_int=0\n len_x=len(x)\n for y in range(d):\n if x[y]=="1":\n buf_lst=pc[y]\n buf_int+=(y+1)*100*buf_lst[0]+buf_lst[1]\n cnt+=buf_lst[0]\n if buf_int<g:\n buf_index=x.rfind("0")\n buf_lst=pc[buf_index]\n i=buf_lst[0]\n for z in range(1,i):\n if buf_int+(buf_index+1)*100*z>=g:\n buf_int+=(buf_index+1)*100*z\n cnt+=z\n break\n if buf_int>=g:\n lst_cnt.append(cnt)\nprint(min(lst_cnt))']
['Wrong Answer', 'Accepted']
['s377614370', 's581422057']
[3064.0, 3064.0]
[40.0, 39.0]
[820, 805]
p03290
u580904613
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d, g = map(int, input().split())\np = [0]*d\nc = [0]*d\nfor i in range(d):\n p[i], c[i] = map(int, input().split())\n \nans = 10**6\n \nfor i in range(2**d):\n cnt = 0\n sum = 0\n k = -1\n for j in range(d):\n if (i >> j) & 1:\n sum += (j+1)*100*p[j]+c[j]\n cnt += p[j]\n else:\n k = j\n if sum < g:\n s1 = 100 * (k + 1)\n need = (g - sum + s1 - 1) // s1\n if need >= p[k]:\n continue\n cnt += need\n ans = min(ans, cnt)\nprint(ans)', 'd, g = map(int, input().split())\np = [0]*d\nc = [0]*d\nfor i in range(d):\n p[i], c[i] = map(int, input().split())\n\nans = 10**6\n\nfor i in range(2**d):\n cnt = 0\n sum = 0\n k = -1\n for j in range(d):\n if (i >> j) & 1:\n sum += (j+1)*100*p[j]+c[j]\n cnt += p[j]\n else:\n k = j\n if sum < g:\n s1 = 100 * (k + 1)\n need = (g - sum + s1 - 1) // s1\n \n if need >= p[k]:\n continue\n \n cnt += need\n \n ans = min(ans, cnt)\n \nprint(ans)\n \n ', 'd, g = map(int, input().split())\np = [0]*d\nc = [0]*d\nfor i in range(d):\n p[i], c[i] = map(int, input().split())\n \nans = 10**6\n\nfor i in range(2**d):\n cnt = 0\n sum = 0\n k = -1\n for j in range(d):\n if (i >> j) & 1:\n sum += (j+1)*100*p[j]+c[j]\n cnt += p[j]\n else:\n k = j\n if sum < g:\n s1 = 100 * (k + 1)\n need = (g - sum + s1 - 1) // s1\n if need >= p[k]:\n continue\n cnt += need\n ans = min(ans, cnt)\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s035405838', 's902156059', 's134616773']
[3064.0, 3064.0, 3064.0]
[22.0, 17.0, 22.0]
[454, 492, 451]
p03290
u585742242
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['# -*- coding: utf-8 -*-\nD, G = map(int, input().split())\n\ncp = [tuple(map(int, input().split())) for i in range(D)]\ncpg = [(c, (i + 1) * 100, (i + 1) * 100 * c + p)\n for i, (c, p) in enumerate(cp)]\n\ncnt = 0\nwhile True:\n c, p, g = cpg.pop()\n\n if G - g > 0:\n G -= g\n cnt += c\n continue\n\n else:\n\n if G / p < c:\n cnt += G // p if G % p == 0 else G // p + 1\n break\n\n if cpg:\n cn, pn, gn = cpg[-1]\n if G - gn <= 0 and cn < c:\n cnt += cn\n break\n else:\n cnt += c\n break\n\nprint(cnt)\n', '# -*- coding: utf-8 -*-\nD, G = map(int, input().split())\n\ncp = [tuple(map(int, input().split())) for i in range(D)]\ncpg = [(c, (i + 1) * 100, (i + 1) * 100 * c + p)\n for i, (c, p) in enumerate(cp)]\n\ncnt = 0\nwhile True:\n\n c, p, g = cpg.pop()\n if G - g > 0:\n if cpg:\n cn, pn, gn = cpg[-1]\n if G - gn <= 0:\n cnt += cn\n break\n\n G -= g\n cnt += c\n continue\n\n else:\n\n if G / p < c:\n cnt += G // p if G % p == 0 else G // p + 1\n break\n\n if cpg:\n cn, pn, gn = cpg[-1]\n if G - gn <= 0 and cn < c:\n cnt += cn\n break\n\n else:\n cnt += c\n break\n\nprint(cnt)\n', '# -*- coding: utf-8 -*-\nfrom itertools import product\n\nD, G = map(int, input().split())\npc_table = [tuple(map(int, input().split())) for _ in range(D)]\n\nbit_table = list(product([0, 1], repeat=D))\ncnts = []\nfor bits in bit_table:\n g = sum([\n pc_table[i][1] + 100 * (i + 1) * pc_table[i][0]\n for i, bit in enumerate(bits) if bit\n ])\n cnt = sum([pc_table[i][0] for i, bit in enumerate(bits) if bit])\n\n max_p = 0 if sum(bits) == D else max(\n [i for i, bit in enumerate(bits) if not bit])\n for _ in range(pc_table[max_p][0]):\n\n if g >= G:\n cnts.append(cnt)\n break\n else:\n g += 100 * (max_p + 1)\n cnt += 1\n\nprint(min(cnts))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s072905942', 's874016275', 's213074453']
[3064.0, 3064.0, 3188.0]
[17.0, 17.0, 47.0]
[627, 754, 713]
p03290
u592248346
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["d,g = map(int,input().split())\np,c = [],[]\nans = float('inf')\nfor i in range(d):\n x,y = map(int,input().split())\n p.append(x)\n c.append(y)\nfor i in range((1<<d)):\n tmp,cnt = 0,0\n for j in range(d):\n if i&(1<<j):\n tmp = tmp + 100*(j+1)*p[j]+c[j]\n cnt += p[j]\n if tmp>=g:\n if cnt<ans: print(cnt);ans=cnt\n else:\n for j in range(d-1,-1,-1):\n if i&(1<<j): continue\n for k in range(p[j]):\n if tmp>=g: break\n tmp = tmp + 100*(j+1)\n cnt+=1\n if cnt<ans: ans = cnt\nprint(ans)", "d,g = map(int,input().split())\np,c = [],[]\nans = float('inf')\nfor i in range(d):\n x,y = map(int,input().split())\n p.append(x)\n c.append(y)\nfor i in range((1<<d)):\n tmp,cnt = 0,0\n for j in range(d):\n if i&(1<<j):\n tmp = tmp + 100*(j+1)*p[j]+c[j]\n cnt += p[j]\n if tmp>=g:\n if cnt<ans: ans=cnt\n else:\n for j in range(d-1,-1,-1):\n if i&(1<<j): continue\n for k in range(p[j]):\n if tmp>=g: break\n tmp = tmp + 100*(j+1)\n cnt+=1\n if cnt<ans: ans = cnt\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s704505042', 's480185736']
[9232.0, 9160.0]
[127.0, 128.0]
[603, 592]
p03290
u594567187
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import math\nlength, goal = map(int, input().split(" "))\nproblems, bonus = [], []\nfor i in range(length):\n a, b = map(int, input().split(" "))\n problems.append(a)\n bonus.append(b)\nproblems = problems[::-1]\nbonus = bonus[::-1]\nanswer = float("inf")\nfor bit in range(length ** 2):\n temp_ans = 0\n temp_sum = 0\n for i in range(length):\n temp_score = (length - i) * 100\n if bit & (1 << i):\n temp_ans += problems[i]\n temp_sum += bonus[i] + temp_score * problems[i]\n print(bit, temp_ans, temp_sum)\n if temp_sum >= goal:\n answer = min(answer, temp_ans)\n else:\n for i in range(length):\n temp_score = (length - i) * 100\n if not(bit & (1 << i)):\n if temp_score * (problems[i] - 1) + temp_sum >= goal:\n temp_ans += int(math.ceil((goal - temp_sum) / temp_score))\n print(math.ceil((goal - temp_sum) / temp_score))\n answer = min(answer, temp_ans)\n break\n else:\n temp_ans += problems[i] - 1\n temp_sum += temp_score * (problems[i] - 1)\n if temp_sum >= goal:\n answer = min(answer, temp_ans)\nprint(answer)', 'import math\nlength, goal = map(int, input().split(" "))\nproblems, bonus = [], []\nfor i in range(length):\n a, b = map(int, input().split(" "))\n problems.append(a)\n bonus.append(b)\nproblems = problems[::-1]\nbonus = bonus[::-1]\nanswer = float("inf")\nfor bit in range(length ** 2):\n temp_ans = 0\n temp_sum = 0\n for i in range(length):\n temp_score = (length - i) * 100\n if bit & (1 << i):\n temp_ans += problems[i]\n temp_sum += bonus[i] + temp_score * problems[i]\n print(bit, temp_ans, temp_sum)\n if temp_sum >= goal:\n answer = min(answer, temp_ans)\n else:\n for i in range(length):\n temp_score = (length - i) * 100\n if not(bit & (1 << i)):\n if temp_score * (problems[i] - 1) + temp_sum >= goal:\n temp_ans += int(math.ceil((goal - temp_sum) / temp_score))\n \n answer = min(answer, temp_ans)\n break\n else:\n temp_ans += problems[i] - 1\n temp_sum += temp_score * (problems[i] - 1)\n if temp_sum >= goal:\n answer = min(answer, temp_ans)\nprint(answer)', 'import math\nlength, goal = map(int, input().split(" "))\nnums = []\nsumall = []\nfor i in range(length):\n a, b = map(int, input().split(" "))\n nums.append(a)\n sumall.append(a * (i + 1) * 100 + b)\nanswer = float("inf")\nfor bit in range(2 ** length):\n temp = []\n for i in range(length - 1, -1, -1):\n if bit & (1 << i):\n temp.append(i)\n temp_length = len(temp)\n for tempbit in range(2 ** temp_length):\n temp_sum = 0\n choosed = 0\n for i in range(temp_length):\n if tempbit & (1 << i):\n temp_sum += sumall[temp[i]]\n choosed += nums[temp[i]]\n if temp_sum >= goal:\n answer = min(answer, choosed)\n break\n else:\n if temp_sum + (nums[temp[i]] - 1) * (temp[i] + 1) * 100 >= goal:\n answer = min(answer, choosed + int(math.ceil((goal - temp_sum) / (100 * (temp[i] + 1)))) )\n break\n temp_sum += (nums[temp[i]] - 1) * (temp[i] + 1) * 100\n choosed += nums[temp[i]] - 1\n # print(bin(bit), bin(tempbit), temp_sum, choosed, answer)\n # print(answer, bin(bit))\nprint(answer)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s458734042', 's518589482', 's182638480']
[3064.0, 3064.0, 3316.0]
[19.0, 19.0, 304.0]
[1246, 1248, 1208]
p03290
u597622207
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d, g = map(int, input().split())\npc = [list(map(int, input().split())) for i in range(d)]\nprint(pc)\nans = float("inf")\n\n\n\ndef dfs(i,sum,count,rest):\n \n global ans\n if i == d:\n \n if sum < g:\n use = max(rest)\n n = min(pc[use-1][0], -(-(g-sum)//(use*100)))\n count += n\n sum += n*use * 100\n \n \n if sum >= g:\n ans = min(ans, count)\n \n else:\n \n \n dfs(i + 1, sum, count, rest)\n \n dfs(i + 1, sum + pc[i][0] * (i+1) * 100 + pc[i][1], count + pc[i][0], rest - {i+1})\n\n\ndfs(0,0,0,set(range(1,d + 1)))\n\n\nprint(ans)', 'd, g = map(int, input().split())\npc = [list(map(int, input().split())) for i in range(d)]\nans = float("inf")\n\n\n\ndef dfs(i,sum,count,rest):\n \n global ans\n if i == d:\n \n if sum < g:\n use = max(rest)\n n = min(pc[use-1][0], -(-(g-sum)//(use*100)))\n count += n\n sum += n*use * 100\n \n \n if sum >= g:\n ans = min(ans, count)\n \n else:\n \n \n dfs(i + 1, sum, count, rest)\n \n dfs(i + 1, sum + pc[i][0] * (i+1) * 100 + pc[i][1], count + pc[i][0], rest - {i+1})\n\n\ndfs(0,0,0,set(range(1,d + 1)))\n\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s174745694', 's113038874']
[3064.0, 3064.0]
[19.0, 20.0]
[1382, 1372]
p03290
u600608564
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['from itertools import product\n\nd, g = map(int, input().split())\nprob = []\nfor i in range(1, d + 1):\n p, c = map(int, input().split())\n prob.append((i * 100, p, c)) # score, num, bonus\n\nans = 1000000000\n\nfor prd in product([0, 1], repeat=d):\n cnt = 0\n allScore = 0\n for j, (score, num, bonus) in zip(prd, prob):\n if j == 1:\n cnt += num\n allScore += score * num + bonus\n\n if allScore < g:\n for j, (score, num, bonus) in zip(prd, prob):\n if j == 0 and (score * num >= g - allScore):\n rest = (g - allScore) // score\n cnt += rest\n allScore += score * rest\n break\n\n if allScore >= g:\n ans = min(ans, cnt)\n\nprint(ans)\n', 'd, g = map(int, input().split())\nnum_bonus = [list(map(int, input().split())) for _ in range(d)]\nall_num = 0\n\n\nfor i in range(d):\n all_num += num_bonus[i][0]\n\nnum_bonus.reverse()\nscore = 0\ncnt = 0\np_i = d\n\nfor i in range(d):\n\n for j in range(num_bonus[i][0]):\n cnt += 1\n score += 100 * p_i\n if score >= g:\n print(cnt)\n exit(0)\n\n score += num_bonus[i][1]\n p_i -= 1\n', 'from itertools import product\n\nd, g = map(int, input().split())\nprob = []\nfor i in range(1, d + 1):\n p, c = map(int, input().split())\n prob.append((i * 100, p, c)) # score, num, bonus\n\nans = 1000000000\n\nfor prd in product([0, 1], repeat=d):\n cnt = 0\n allScore = 0\n for j, (score, num, bonus) in zip(prd, prob):\n if j == 1:\n cnt += num\n allScore += score * num + bonus\n\n if allScore < g:\n for j, (score, num, bonus) in zip(prd, prob):\n if j == 0 and (score * num >= g - allScore):\n rest = (g - allScore) // score\n cnt += rest\n allScore += score * rest\n break\n\n if allScore >= g:\n ans = min(ans, cnt)\n\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s666653407', 's683407679', 's059045165']
[3064.0, 3064.0, 3188.0]
[23.0, 17.0, 24.0]
[766, 419, 758]
p03290
u604839890
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['from itertools import combinations\nN, M = map(int, input().split())\nlink = [[0 for i in range(N)] for j in range(N)]\nfor m in range(M):\n x, y = map(int, input().split())\n link[x-1][y-1] = 1\n link[y-1][x-1] = 1\n\nfor i in range(N,1,-1): # N, N-1, N-2, ... 2\n for comb in combinations(range(N),i):\n for c in combinations(comb, 2): \n if (link[c[0]][c[1]] == 0): \n break\n else: \n print (i)\n exit()\nprint (1)', 'd, g = map(int, input().split())\npc = [list(map(int, input().split())) for _ in range(d)]\n\nans = 100*11\nfor i in range(2**d):\n sum = 0\n cnt = 0\n a = []\n for j in range(d):\n if (i >> j) & 1 == 1:\n sum += (j+1)*100*pc[j][0] + pc[j][1]\n cnt += pc[j][0]\n a.append(j)\n if sum < g:\n for j in range(d):\n if d-j-1 not in a:\n for k in range(pc[d-j-1][0]):\n if sum >= g:\n break\n sum += (d-j)*100\n cnt += 1\n ans = min(ans, cnt)\nprint(ans)']
['Runtime Error', 'Accepted']
['s383424791', 's185347372']
[9084.0, 9148.0]
[27.0, 125.0]
[640, 598]
p03290
u619819312
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['a,b=map(int,input().split())\nc=[0]+[list(map(int,input().split()))for i in range(n)]\ndef f(s,t):\n if t==0:\n return 10000007\n else:\n l=min(s//(i*100),c[i][0])\n k=100*i*l\n if n==c[i][0]:\n l+=s[i][1]\n if l<G:\n n+=f(s-l,i-1)\n return min(n,f(s,i-1))\nprint(f(b,a))', 'a,b=map(int,input().split())\nc=[0]+[list(map(int,input().split()))for i in range(a)]\ndef f(t,s):\n if t==0:\n return 10000007\n else:\n l=min(s//(t*100),c[t][0])\n k=100*i*l\n if n==c[t][0]:\n l+=s[t][1]\n if l<G:\n n+=f(t-1,s-l)\n return min(n,f(t-1,s))\nprint(f(a,b))', 'a,b=int(input())\nc=[0]+[list(map(int,input().split()))for i in range(n)]\ndef f(s,t):\n if t==0:\n return 10000007\n else:\n l=min(s//(i*100),c[i][0])\n k=100*i*l\n if n==c[i][0]:\n l+=s[i][1]\n if l<G:\n n+=f(s-l,i-1)\n return min(n,f(s,i-1))\nprint(f(b,a))', 'd,g=map(int,input().split())\ns=[list(map(int,input().split()))for i in range(d)]\ndef dfs(d,g):\n if d==0:\n return 1e9\n l=min(g//(d*100),s[d-1][0])\n k=100*d*l\n if l==s[d-1][0]:\n k+=s[d-1][1]\n if k<g:\n l+=dfs(d-1,g-k)\n return min(l,dfs(d-1,g))\nprint(dfs(d,g))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s055591620', 's545827652', 's940480826', 's937763592']
[3064.0, 3064.0, 3064.0, 3064.0]
[18.0, 18.0, 18.0, 19.0]
[328, 328, 316, 295]
p03290
u626337957
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["S = input()\nT = input()\nA = S\nif S == T:\n print('Yes')\nelse:\n eq = False\n for i in range(len(S)):\n A = A[-1] + A[0:-1]\n if A == T:\n eq = True\n break\n if eq:\n print('Yes')\n else:\n print('No')\n \n", 'import math\n\nD, G = map(int, input().split())\nans = 10**7\nproblems = [tuple(map(int, input().split())) for _ in range(D)]\nfor num in range(2**D):\n solve = 0\n point = 0\n last = -1\n for i in range(D):\n if num>>i&1:\n point += problems[i][1] + (i+1)*100*problems[i][0]\n solve += problems[i][0]\n else:\n last = i\n if last == -1:\n ans = min(ans, solve)\n else:\n rest = G - point\n if rest <= 0:\n ans = min(ans, solve)\n else:\n if rest <= (last+1)*100*problems[last][0]:\n ans = min(ans, solve+math.ceil(rest/((last+1)*100)))\nprint(ans)']
['Wrong Answer', 'Accepted']
['s643199251', 's203373335']
[3060.0, 3064.0]
[17.0, 22.0]
[221, 580]
p03290
u626468554
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d,g = map(int,input().split())\nli = []\n\nfor i in range(d):\n p,c = map(int,input().split())\n li.append([p,c])\n\nans = 10**9\nfor i in range(1<<d):\n ttl = 0\n cnt = 0\n memo = [0 for i in range(d)]\n for j in range(d):\n if (i>>j)&1:\n ttl += li[j][1]+(j+1)*li[j][0]*100\n cnt += li[j][0]\n memo[j] = 1\n \n if ttl < g:\n memo2 = g- ttl\n for j in range(d-1,-1,-1):\n if memo[j] == 0:\n if memo2%(100*(j+1)) == 0:\n cnt += memo2//(100*(j+1))\n ttl += (memo2//(100*(j+1)))*(100*(j+1))\n else:\n cnt += memo2//(100*(j+1))+1\n ttl += (memo2//(100*(j+1))+1)*(100*(j+1))\n break\n if ttl >= g:\n ans = min(ans,cnt)\n \n if ans == cnt:\n print(memo,ttl)\n \n\nprint(ans)\n\n', 'd,g = map(int,input().split())\nli = []\n\nfor i in range(d):\n p,c = map(int,input().split())\n li.append([p,c])\n\nans = 10**9\nfor i in range(1<<d):\n ttl = 0\n cnt = 0\n memo = [0 for i in range(d)]\n for j in range(d):\n if (i>>j)&1:\n ttl += li[j][1]+(j+1)*li[j][0]*100\n cnt += li[j][0]\n memo[j] = 1\n \n if ttl < g:\n memo2 = g- ttl\n for j in range(d-1,-1,-1):\n if memo[j] == 0:\n if memo2%(100*(j+1)) == 0:\n cnt2 = min(memo2//(100*(j+1)),li[j][0]-1)\n cnt += cnt2\n ttl += cnt2*(100*(j+1))\n #print(44444444)\n else:\n cnt2 = min(memo2//(100*(j+1)+1),li[j][0]-1)\n cnt += cnt2\n ttl += cnt2*(100*(j+1))\n break\n if ttl >= g:\n ans = min(ans,cnt)\n \n if ans == cnt:\n \n \n \n\nprint(ans)\n\n', 'd,g = map(int,input().split())\nli = []\n\nfor i in range(d):\n p,c = map(int,input().split())\n li.append([p,c])\n\nans = 10**9\nfor i in range(1<<d):\n ttl = 0\n cnt = 0\n memo = [0 for i in range(d)]\n for j in range(d):\n if (i>>j)&1:\n ttl += li[j][1]+(j+1)*li[j][0]*100\n cnt += li[j][0]\n memo[j] = 1\n \n if ttl < g:\n memo2 = g- ttl\n for j in range(d-1,-1,-1):\n if memo[j] == 0:\n if memo2%(100*(j+1)) == 0:\n cnt2 = min(memo2//(100*(j+1)),li[j][0]-1)\n cnt += cnt2\n ttl += cnt2*(100*(j+1))\n #print(44444444)\n else:\n cnt2 = min(((memo2//(100*(j+1)))+1),li[j][0]-1)\n #print(((memo2//(100*(j+1)))+1))\n cnt += cnt2\n ttl += cnt2*(100*(j+1))\n break\n if ttl >= g:\n ans = min(ans,cnt)\n""" \n if ans == cnt:\n print(memo,ttl,111111)\n""" \n \n\nprint(ans)\n\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s094313691', 's837497030', 's008214521']
[3064.0, 3064.0, 3064.0]
[25.0, 17.0, 25.0]
[887, 999, 1059]
p03290
u631277801
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = map(int, input().split())\nPC = [tuple(map(int, input().split())) for _ in range(D)]\n\nprint(PC)\n\n\ncomp = [100*(i+1)*PC[i][0] + PC[i][1] for i in range(D)]\n\n\n\nans = sum([PC[i][0] for i in range(D)])\nfor bit in range(1<<D):\n \n \n point = 0\n prob = 0\n \n print("init",bit,ans,prob,point)\n \n for j in range(D-1, -1, -1):\n if bit & (1<<j):\n point += comp[j]\n prob += PC[j][0]\n\n \n if point >= G:\n ans = min(ans,prob)\n continue\n \n \n else:\n for j in range(D-1, -1, -1):\n if bit & (1<<j):\n continue\n else:\n if point + 100*(j+1)*(PC[j][0]-1) < G:\n point += 100*(j+1)*(PC[j][0]-1)\n prob += (PC[j][0]-1)\n else:\n temp = (G-point)//(100*(j+1)) + bool((G-point)%(100*(j+1)))\n point += 100*(j+1)*temp\n prob += temp\n \n if point >= G:\n ans = min(ans,prob)\n break\n \n\nprint(ans)', '\nD,G = 5,25000\nprob_num = [20,40,50,30,1]\ncomp = [1000,1000,1000,1000,1000,1000]\n\ncomp_point = []\nfor i in range(D):\n comp_point.append((100*(i+1)*prob_num[i]+comp[i]))\n\n\nres = G\nans = 0\nwhile res>0:\n req_prob = []\n temp_min = []\n temp_value = []\n for i in range(D):\n if prob_num[i] == 0:\n req_prob.append(10000000)\n elif res>=100*(i+1)*prob_num[i]:\n req_prob.append(prob_num[i])\n else:\n req_prob.append((res//(100*(i+1))) + bool(res%(100*(i+1))))\n \n for i in range(D):\n temp_min.append(min(res,comp_point[i]))\n \n for i in range(D):\n temp_value.append(temp_min[i]/req_prob[i])\n \n choice = temp_value.index(max(temp_value))\n \n ans += req_prob[choice]\n if 100*(choice+1)*req_prob[choice] < comp_point[choice]:\n\n res -= 100*(choice+1)*req_prob[choice]\n else:\n res -= comp_point[choice]\n prob_num[choice] -= req_prob[choice]\n \n# print(ans,res)\n \nprint(ans)', 'D,G = map(int, input().split())\nprob_num = []\nbonus = []\ncomp_pt = []\nfor i in range(D):\n p,b = map(int, input().split())\n prob_num.append(p)\n bonus.append(b)\n comp_pt.append(100*(i+1)*p+b)\n\ndef dfs(hascomp:str, target:int, prob:int, depth:int) -> int:\n if target <= 0:\n \n return prob\n \n elif depth == D:\n for i in range(D-1,-1,-1):\n if hascomp[i] == "n":\n if target <= 100*(i+1)*(prob_num[i]-1):\n prob += (target//(100*(i+1)))+bool(target%(100*(i+1)))\n print(hascomp, depth, prob)\n return prob\n \n else:\n prob += (prob_num[i]-1)\n target -= 100*(i+1)*(prob_num[i]-1)\n \n if target > 0:\n \n return 10**5\n \n else:\n new_tar = target-comp_pt[depth]\n new_prob = prob + prob_num[depth]\n return min(dfs(hascomp+"y",new_tar, new_prob, depth+1),\n dfs(hascomp+"n",target, prob, depth+1))\n \n\nans = dfs("",G,0,0)\nprint(ans)', 'import sys\nstdin = sys.stdin\n\nsys.setrecursionlimit(10**5)\n\ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nd,g = li()\npc = []\nfor _ in range(d):\n pc.append(tuple(li()))\n \nans = 10**10\nfor bit in range(1<<d):\n point = 0\n probs = 0\n for b in range(d):\n if bit & (1<<b):\n point += (100*(b+1)*pc[b][0] + pc[b][1])\n probs += pc[b][0]\n \n if point >= g:\n ans = min(ans, probs)\n \n else:\n\n res = g-point\n for q in range(d-1, -1, -1):\n if bit & (1<<q):\n continue\n \n if 100*(q+1)*(pc[q][0]-1) >= res:\n probs += -(-res // (100*(q+1)))\n res = 0\n \n else:\n res -= 100*(q+1)*(pc[q][0]-1)\n probs += pc[q][0]\n \n if res == 0: \n ans = min(ans,probs)\n\n \nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s097511737', 's881537784', 's964391823', 's699311880']
[3572.0, 3064.0, 3188.0, 3064.0]
[29.0, 18.0, 22.0, 27.0]
[1298, 1007, 1161, 1233]
p03290
u633548583
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G=map(int,input().split())\np=[]\nc=[]\nfor i in range(D):\n a,b=map(int,input().split())\n p.append(a)\n c.append(b)\nten=0\nmondaisu=0\nans=100000\n\nfor i in range(2**D):\n for j in range(D):\n if (i>>j)&1==1:\n ten+=(j+1)*100*p[j]+c[j]\n mondaisu+=p[j]\n else:\n k=j\n if ten>=G:\n if ans>mondaisu:\n ans=mondaisu\n else:\n if G-ten<=(k+1)*100*p[k]:\n mondaisu+=(G-ten-1)//(k+1)*100+1\n if ans>mondaisu:\n ans=mondaisu\nprint(ans)\n', 'D,G=map(int,input().split())\np=[]\nc=[]\nfor i in range(D):\n a,b=map(int,input().split())\n p.append(a)\n c.append(b)\nsum=0\ncnt=[]\nfor i in range(D):\n for j in range(2**p[i]):\n for k in range(p[i]):\n if ((j>>k)&1):\n sum+=100*i\n if j==2**p[i]-1:\n sum+=c[i]\n if sum>=D:\n cnt.append(bin(j).count("1"))\nprint(min(cnt))\n ', 'D,G=map(int,input().split())\np=[]\nc=[]\nfor i in range(D):\n a,b=map(int,input().split())\n p.append(a)\n c.append(b)\nten=0\nmondaisu=0\nans=100000\n\nfor i in range(2**D):\n for j in range(D):\n if ((i>>j)&1):\n ten+=(j+1)*100*p[j]+c[j]\n mondaisu+=p[j]\n else:\n k=j\n if ten>=G:\n if ans>mondaisu:\n ans=mondaisu\n else:\n if G-ten<=(k+1)*100*p[k]:\n mondaisu+=(G-ten-1)//(k+1)*100+1\n if ans>mondaisu:\n ans=mondaisu\nprint(ans)', 'D,G=map(int,input().split())\np=[]\nc=[]\nfor i in range(D):\n a,b=map(int,input().split())\n p.append(a)\n c.append(b)\n\nans=100000\n\nfor i in range(2**D):\n ten=0\n mondaisu=0\n for j in range(D):\n if ((i>>j)&1):\n ten+=(j+1)*100*p[j]+c[j]\n mondaisu+=p[j]\n else:\n k=j\n if ten>=G:\n if ans>mondaisu:\n ans=mondaisu\n else:\n if G-ten<=(k+1)*100*p[k]:\n mondaisu+=(G-ten-1)//((k+1)*100)+1\n if ans>mondaisu:\n ans=mondaisu\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s428237463', 's506535338', 's544733139', 's818448442']
[3064.0, 4632.0, 3064.0, 3064.0]
[22.0, 2104.0, 22.0, 22.0]
[538, 426, 536, 548]
p03290
u634159866
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = map(int, input().split())\nList = [list(map(int, input().split())) for _ in range(D)]\n\nfor i in range(D):\n b = [[List[i][0], List[i][0]*(i+1)*100+List[i][1]] for i in range(D)]\n \nm = 10**9\nfor j in range(1, 2**D):\n cnt = 0\n score = 0\n flg = 0\n for k in range(D):\n if ((j>>k)&1):\n cnt+=b[k][0]\n score+=b[k][1]\n flg+=1\n used = k\n else:\n unused = k\n if G<=score:\n if flg==1:\n cnt = -(-G//((used+1)*100))\n if cnt<m:\n m = cnt\n else:\n if cnt<m:\n m = cnt\n \n else: \n diff = G-score\n offset = -(-diff//((unused+1)*100))\n cnt += offset\n if offset<List[unused][0]:\n if cnt<m:\n m = cnt\nprint(m)', 'D, G = map(int, input().split())\nList = [list(map(int, input().split())) for _ in range(D)]\n\nfor i in range(D):\n b = [[List[i][0], List[i][0]*(i+1)*100+List[i][1]] for i in range(D)]\n \nm = 10**9\nfor j in range(2**D):\n cnt = 0\n score = 0\n flg = 0\n for k in range(D):\n if ((j>>k)&1):\n cnt+=b[k][0]\n score+=b[k][1]\n flg+=1\n used = k\n else:\n unused = k\n if G<=score:\n if flg==1:\n cnt = min(-(-G//((used+1)*100)), cnt)\n if cnt<m:\n m = cnt\n else:\n if cnt<m:\n m = cnt\n \n else: \n diff = G-score\n offset = -(-diff//((unused+1)*100))\n cnt += offset\n if offset<List[unused][0]:\n if cnt<m:\n m = cnt\nprint(m)']
['Wrong Answer', 'Accepted']
['s886236865', 's865512290']
[3188.0, 3064.0]
[23.0, 21.0]
[827, 834]
p03290
u637413735
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport pdb\nimport sys\nF = sys.stdin\n\nD, G = map(int,F.readline().split())\np = []\nc = []\nall_score = []\nmaisu = 0\nans = 0\nsum = 0\nall_selected = [0]*D\nfor k in range(D):\n p1, c1 = map(int,F.readline().split())\n p.append(p1)\n c.append(c1)\n all_score.append(100 * k * p1 + c1)\n\nfor bit in range(1<<D):\n for i in range(D):\n if bit & (1<<i):\n all_selected[i] = 1\n sum += all_score[i]\n maisu += p[i]\n\n nokori = G - sum\n if nokori <= 0:\n if ans == 0:\n ans = maisu\n else:\n ans = min(ans, maisu)\n continue\n for j in range(D)[::-1]:\n if all_selected[j] == 0:\n nokorimaisu = (nokori // (100 * j)) + 1\n if nokorimaisu <= p[j]:\n maisu += nokorimaisu\n if ans == 0:\n ans = maisu\n else:\n ans = min(ans, maisu)\n break\n\n\n\n all_selected = [0]*D\n maisu = 0\n sum = 0\n\nprint(ans)\n', '#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport pdb\nimport sys\nimport math\nF = sys.stdin\n\nD, G = map(int,F.readline().split())\np = []\nc = []\nall_score = []\nmaisu = 0\nans = 0\nsum = 0\nall_selected = [0]*D\nfor k in range(D):\n p1, c1 = map(int,F.readline().split())\n p.append(p1)\n c.append(c1)\n all_score.append(100 * (k+1) * p1 + c1)\n\nfor bit in range(1<<D):\n for i in range(D):\n if bit & (1<<i):\n all_selected[i] = 1\n sum += all_score[i]\n maisu += p[i]\n\n nokori = G - sum\n if nokori <= 0:\n if ans == 0:\n ans = maisu\n else:\n ans = min(ans, maisu)\n all_selected = [0]*D\n maisu = 0\n sum = 0\n continue\n\n for j in range(D)[::-1]:\n if all_selected[j] == 0:\n nokorimaisu = math.ceil(nokori / (100 * (j+1)))\n if nokorimaisu <= p[j]:\n maisu += nokorimaisu\n if ans == 0:\n ans = maisu\n else:\n ans = min(ans, maisu)\n break\n\n all_selected = [0]*D\n maisu = 0\n sum = 0\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s638919322', 's540765301']
[5360.0, 5548.0]
[51.0, 51.0]
[1045, 1131]
p03290
u649326276
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['dg = input().split(“ “);\nd = int(dg[0]);\ng = int(dg[1]);\np = [0]*d;\nc = [0]*d;\nfor i in range(d) :\n s = input().split(“ “);\n p[i] = int(s[0]);\n c[i] = int(s[1]);\n\nans = 0;\nfor i in range(sum(p)) :\n sump = 0;\n for j in range(len(p)) :\n all = 0;\n for m in range(p[j]) :\n if(i & 2**(sump+m)>>(sump+m)) :\n ans += (j+1)*100;\n all += 1;\n if(all == p[j]) :\n ans += c[j];\n sump += p[i];\nprint(ans);', "dg = input().split(' ');\nd = int(dg[0]);\ng = int(dg[1]);\np = [0]*d;\nc = [0]*d;\nfor i in range(d) :\n s = input().split(' ');\n p[i] = int(s[0]);\n c[i] = int(s[1]);\n\nans = sum(p);\nfor i in range(2**d) :\n sumpoint = 0;\n luck = -1;\n point = 0;\n for j in range(d-1,-1,-1) :\n if((i & 2**j)>>j) :\n sumpoint += (j+1)*100*p[j] + c[j];\n point += p[j];\n elif(luck<0) :\n luck = j\n k = 0;\n while k < p[luck] and sumpoint < g :\n sumpoint += (luck+1)*100;\n point += 1;\n k+= 1;\n if sumpoint >= g and point < ans :\n ans = point;\n\nprint(ans);"]
['Runtime Error', 'Accepted']
['s596370306', 's886043444']
[3192.0, 3064.0]
[19.0, 63.0]
[493, 628]
p03290
u649373416
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G=[ int(it) for it in input().split() ]\nli = [ [ int(it) for it in input().split() ] for i in range(D) ]\n\nimport itertools as ite\ncmin = 100000000000000000\nfor cli in ite.product( *([[0,1]]*D) ):\n \n s = 0\n c = 0\n for i in range(D):\n if cli[i]==1:\n s += li[i][1] + (i+1)*100*li[i][0]\n c += li[i][0]\n \n ds = G-s\n \n for i in range(D-1,-1,-1):\n if (ds<=0):\n break\n if cli[i]==0:\n toku = (ds-1)//((i+1)*100)+1\n toku = min(toku,li[i][0])\n c += toku\n ds -= toku*(i+1)*100\n if (ds<=0):\n break\n if (ds<=0):\n cmin = min(cmin,c)\n else:\nprint (cmin)', 'D,G=[ int(it) for it in input().split() ]\nli = [ [ int(it) for it in input().split() ] for i in range(D) ]\n\nimport itertools as ite\ncmin = 100000000000000000\nfor cli in ite.product( *([[0,1]]*D) ):\n \n s = 0\n c = 0\n for i in range(D):\n if cli[i]==1:\n s += li[i][1] + (i+1)*100*li[i][0]\n c += li[i][0]\n \n \n ds = G-s\n \n for i in range(D-1,-1,-1):\n if (ds<=0):\n break\n if cli[i]==0:\n toku = (ds-1)//((i+1)*100)+1\n toku = min(toku,li[i][0])\n c += toku\n ds -= toku*(i+1)*100\n if (ds<=0):\n cmin = min(cmin,c)\nprint (cmin)', 'D,G=[ int(it) for it in input().split() ]\nli = [ [ int(it) for it in input().split() ] for i in range(D) ]\n\nimport itertools as ite\ncmin = 100000000000000000\nfor cli in ite.product( *([[0,1]]*D) ):\n \n s = 0\n c = 0\n for i in range(D):\n if cli[i]==1:\n s += li[i][1] + (i+1)*100*li[i][0]\n c += li[i][0]\n \n ds = G-s\n \n for i in range(D-1,-1,-1):\n if (ds<=0):\n break\n if cli[i]==0:\n toku = (ds-1)//((i+1)*100)+1\n toku = min(toku,li[i][0])\n c += toku\n ds -= toku*(i+1)*100\n if (ds<=0):\n break\n if (ds<=0):\n cmin = min(cmin,c)\n else:\n pass\nprint (cmin)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s190843004', 's279578836', 's150637497']
[3064.0, 3064.0, 3064.0]
[18.0, 28.0, 28.0]
[606, 592, 615]
p03290
u657994700
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["import math\n\n# print('input >>')\nD, G = map(int, (input().split()))\npc = []\nfor _ in range(D):\n p, c = map(int, (input().split()))\n pc.append((p, c))\n\npoint = 0\nans = []\n\ndef dfs(i, count, point):\n \n if point >= G:\n ans.append(count)\n return\n \n if point + (i + 1) * 100 * (pc[i][0] - 1) >= G:\n count += math.ceil((G - point) / ((i + 1) * 100))\n point += math.ceil((G - point) / ((i + 1) * 100)) * (i + 1) * 100\n ans.append(count)\n if i == 0:\n return\n \n dfs(i-1, count+pc[i][0], point + (i+1)*100 * pc[i][0] + pc[i][1])\n \n dfs(i-1, count, point)\n\ndfs(D-1,0,0)\n\n# print('----------output----------')\nprint(min(ans))", "import math\n\n# print('input >>')\nD, G = map(int, (input().split()))\npc = []\nfor _ in range(D):\n p, c = map(int, (input().split()))\n pc.append((p, c))\n\npoint = 0\nans = []\n\ndef dfs(i, count, point):\n \n c_ = count\n if point >= G:\n ans.append(count)\n return\n \n if point + (i + 1) * 100 * (pc[i][0] - 1) >= G:\n count += math.ceil((G - point) / ((i + 1) * 100))\n ans.append(count)\n \n elif point + (i + 1) * 100 * pc[i][0] + pc[i][1] >= G:\n count += pc[i][0]\n ans.append(count)\n if i == 0:\n return\n \n dfs(i-1, c_+pc[i][0], point + (i+1)*100 * pc[i][0] + pc[i][1])\n \n dfs(i-1, c_, point)\n\ndfs(D-1,0,0)\n\n# print('----------output----------')\nprint(min(ans))"]
['Runtime Error', 'Accepted']
['s541435240', 's751511287']
[3064.0, 3064.0]
[18.0, 18.0]
[827, 926]
p03290
u685263709
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import unionfind', 'D, G = map(int, input().split())\nPC = [list(map(int, input().split())) for i in range(D)]\nPC_new = sorted([(PC[i][0]*100*(i+1) + PC[i][1], PC[i][0]) for i in range(D)],\n key=lambda x: x[1], reverse=True)\n\nans = 99999999\nfor i in range(1<<D):\n ct = 0\n score = 0\n for j in range(D):\n if i>>j&1:\n score += PC[j][1]\n score += PC[j][0] * (j+1) * 100\n ct += PC[j][0]\n for j in range(D-1, -1, -1):\n if i>>j&1: continue\n if score >= G: break\n g = (j+1)*100\n got = (G-score+g-1)//g\n score += min(got, PC[j][0]) * g\n ct += min(got, PC[j][0])\n ans = min(ans, ct)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s175544241', 's220296522']
[2940.0, 3444.0]
[17.0, 52.0]
[16, 675]
p03290
u686390526
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G=map(int, input().split())\nli = []\nfor i in range(D):\n li.append(list(map(int, input().split())))\n\nmin_n=10**9\nn = 0\ns=0\nfor ind in range(2**D):\n n=0\n s=0\n if ind==0:\n continue\n for j in range(D):\n if ind>>j & 1:\n s += (j+1)*100*li[j][0]+li[j][1]\n n+=li[j][0]\n print(s)\n if s < G:\n for j in range(D-1,-1,-1):\n if ind>>j & 1 == 0:\n tmp = (G-s) / ((j+1)*100)\n if (G-s) % ((j+1)*100) != 0:\n tmp += 1\n if tmp > 0:\n if tmp==li[j][1]:\n tmp -=1\n s += (j+1)*100*tmp\n n+= tmp\n if s >= G:\n break\n if s >= G:\n if n<min_n:\n # print(ind)\n min_n=n\n\nprint(int(min_n))\n ', 'D,G=map(int, input().split())\nli = []\nfor i in range(D):\n li.append(list(map(int, input().split())))\n\nmin_n=0\nn = 10**9\ns=0\nfor ind in range(2**D):\n n=0\n if ind==0:\n continue\n for j in range(D):\n if ind>>j & 1:\n s += (j+1)*100*li[j][0]+li[j][1]\n n+=li[j][0]\n if s < G:\n for j in range(D-1,-1,-1):\n if ind>>j & 0:\n tmp = s % ((j+1)*100)\n if tmp > 0:\n if tmp==li[j][1]:\n tmp -=1\n s += (j+1)*100*tmp\n n+= tmp\n if s >= G:\n if n<min_n:\n min_n=n\n\nprint(min_n)\n ', 'D,G=map(int, input().split())\nli = []\nfor i in range(D):\n li.append(list(map(int, input().split())))\n\nmin_n=10**9\nn = 0\ns=0\nfor ind in range(2**D):\n n=0\n s=0\n for j in range(D):\n if ind>>j & 1:\n s += (j+1)*100*li[j][0]+li[j][1]\n n+=li[j][0]\n # print(s)\n if s < G:\n for j in range(D-1,-1,-1):\n if ind>>j & 1 == 0:\n tmp = (G-s) / ((j+1)*100)\n if (G-s) % ((j+1)*100) != 0:\n tmp += 1\n if tmp > 0:\n if tmp>=li[j][0]:\n tmp=li[j][0]-1\n s += (j+1)*100*tmp\n n+= tmp\n if s >= G:\n # print(tmp)\n break\n if s >= G:\n if n<min_n:\n # print(ind)\n min_n=n\n\nprint(int(min_n))\n ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s016960796', 's126301418', 's953102036']
[3188.0, 3064.0, 3188.0]
[26.0, 21.0, 29.0]
[687, 550, 691]
p03290
u695811449
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import copy\n\nD,G=map(int,input().split())\n\n\nscore=[None]*D\nfor i in range(D):\n score[i]=list(map(int,input().split()))\n\ncomp=[None]*D\n\nfor i in range(D):\n comp[i]=score[i][0]*(i+1)*100+score[i][1]\n\n\nnumber=0\nfor i in range(D):\n number+=score[i][0]\n\ndplist=[None]*(number+1)\nfor i in range(number+1):\n dplist[i]=[(0,[0 for i in range(D)])]\n\n\ndef scoresolve(X):\n ANS=0\n for i in range(len(X)):\n ANS+=X[i]*(i+1)*100\n if X[i]==score[i][0]:\n ANS+=score[i][1]\n\n return ANS\n\ndplist[number]=(sum(comp),[score[i][0] for i in range(D)])\ndplist[0]=(0,[0 for i in range(D)])\n\ndef DP(x):\n ANS=0\n for i in range(D):\n xx=copy.deepcopy(dplist[x+1][1])\n if xx[i]==0:\n continue\n else:\n xx[i]-=1\n if scoresolve(xx)>ANS:\n retlist=copy.deepcopy(xx)\n retnum=scoresolve(xx)\n ANS=retnum\n\n return (retnum,retlist)\n\nfor i in range(number-1,0,-1):\n #print(dplist)\n dplist[i]=DP(i)\n\nfor i in range(number+1):\n if dplist[i][0]>=G:\n print(i)\n break\n\n\n \n \n', 'import math\n\nD,G=map(int,input().split())\n\n\nscore=[None]*D\nfor i in range(D):\n score[i]=list(map(int,input().split()))\n\n\nimport itertools\nbitlist=list(itertools.product((0,1),repeat=D))\n\ndef xx(a):\n XX=[0 for i in range(D)]\n for i in range(len(a)):\n if a[i]==1:\n XX[i]=score[i][0]\n return XX\n\n\ndef scoresolve(X):\n ANS=0\n for i in range(len(X)):\n ANS+=X[i]*(i+1)*100\n if X[i]==score[i][0]:\n ANS+=score[i][1]\n\n return ANS\n\n\n\n\n\nANS=100000\nfor bit in bitlist:\n ii=xx(bit)\n if scoresolve(ii)>=G:\n ANS=min(ANS,sum(ii))\n else:\n j=D-ii[::-1].index(0)-1\n if G-scoresolve(ii)<=(j+1)*100*score[j][0]:\n ANS=min(ANS,sum(ii)+math.ceil((G-scoresolve(ii))/(j+1)/100))\n\nprint(ANS)\n \n \n\n \n \n \n']
['Wrong Answer', 'Accepted']
['s450952856', 's016317505']
[3824.0, 3188.0]
[152.0, 28.0]
[1112, 831]
p03290
u698501671
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["D,G = map(int,input().split(' '))\nl = [list(map(int,input().split())) for i in range(D)]\n \nans = 10**8\nfor i in range(2**D):\n score = 0\n tmp = 0\n n_list = []\n for j in range(D):\n if (i >> j & 1):\n k = l[j]\n score += (j+1)*100*k[0]+k[1]\n tmp += k[0]\n else:\n n_list.append([j+1]+l[j])\n e_flag = False\n for ii in n_list[::-1]:#[1or2or..,times,bonus]\n for jj in range(ii[1]-1):\n if score<G:\n score += ii[0]*100\n tmp += 1\n else:\n e_flag = True\n break\n if e_flag:\n break\n if score<G:\n continue\n ans = min(ans,tmp)\n print(ans)", 'D, G = map(int, input().split())\nX = [0] + [list(map(int, input().split())) for _ in range(D)]\n\ndef func(i, t):\n if i == 0:\n return 10 ** 9\n \n # Solve all problems, or part of them\n k = min(t // (100 * i), X[i][0])\n s = 100 * i * k\n \n # If all problems are solved, add bonus\n if k == X[i][0]:\n s += X[i][1]\n \n \n if s < t:\n k += func(i - 1, t - s)\n \n # Select minimum number of solved problems\n # k: solve i-th line\n \n return min(k, func(i - 1, t))\n\n# Solve backward\nprint(func(D, G))\n']
['Wrong Answer', 'Accepted']
['s693625401', 's812860374']
[3316.0, 3064.0]
[146.0, 18.0]
[722, 626]
p03290
u698771758
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['def Search(g,L,i):\n if i<0:return 9999\n pS=pC=S = C = 0\n while g > S:\n if i < 0: return 9999\n pS=S\n pC=C\n S+=L[i][0]*L[i][1]*100\n if g > S:\n S+=L[i][2]\n C+=L[i][1]\n i-=1\n print(C,pC,g-pS,L[:i+1],i)\n pC+=min(C,((g-pS-1)//100//L[i+1][0]+1),Search(g-pS,L[:i+1],i))\n return pC\nd,g=map(int,input().split())\nL=[]\nfor i in range(d):\n p,c=map(int,input().split())\n L.append((i+1,p,c))\nprint(Search(g,L,i))', 'def Search(g,t):\n if t<= 0: return 100000000000\n n=min(int(g/(100*t)),p[t-1])\n s=100*t*n\n if n==p[t-1]:\n s=sum[t-1]\n if g>s:\n n+=Search(g-s,t-1)\n return min(n,Search(g,t-1))\nd,g=map(int,input().split())\np=[]\nc=[]\nsum=[]\nfor i in range(d):\n a,b=map(int,input().split())\n p.append(a)\n c.append(b)\nfor i in range(d):\n sum.append((i+1)*100*p[i]+c[i])\nprint(Search(g,d))']
['Wrong Answer', 'Accepted']
['s729655929', 's157374299']
[3188.0, 3064.0]
[19.0, 18.0]
[481, 409]
p03290
u699944218
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['def dfs(i, sum, count, unsolve):\n global ans\n if i == D:\n \n if sum < G:\n use = max(unsolve)\n \n N = min(pc[use-1][0], -(-(g-sum)//(100*use)))\n count += N \n sum += N * 100 * use\n if sum > G:\n ans = min(ans, count)\n else:\n dfs(i + 1, sum, count, unsolve)\n dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], unsolve - {i + 1})\n\nd, g = map(int, input().split())\npc = [list(map(int, input().split())) for i in range(d)]\nans = float("inf")\ndfs(0, 0, 0, set(range(1, d + 1)))\nprint(ans)', 'def dfs(i, sum, count, nokori):\n global ans\n if i == d:\n \n if sum < g:\n use = max(nokori)\n \n n = min(pc[use - 1][0], -(-(g - sum) // (use * 100))) \n count += n\n sum += n * use * 100\n if sum >= g:\n ans = min(ans, count)\n else:\n \n dfs(i + 1, sum, count, nokori)\n dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})\nd, g = map(int, input().split())\npc = [list(map(int, input().split())) for i in range(d)]\nans = float("inf")\ndfs(0, 0, 0, set(range(1, d + 1)))\nprint(ans)']
['Runtime Error', 'Accepted']
['s461006921', 's758221389']
[9048.0, 9144.0]
[29.0, 32.0]
[647, 901]
p03290
u728566015
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = map(int, input().split())\np = [0] * D\nc = [0] * D\nfor i in range(D):\n p[i], c[i] = map(int, input().split())\n\nnum = []\n\nfor i in range(2**D):\n score = 0\n num_tmp = 0 \n not_comp = [] \n for j in range(D):\n if i >> j & 1:\n score += p[j] * 100 * (j + 1) + c[j]\n num_tmp += p[j]\n else:\n not_comp.append(j)\n print("not_comp:", not_comp)\n\n for j in not_comp[::-1]:\n if score < G:\n num_j = min(p[j] - 1, (G - score - 1) // (100 * (j + 1)) + 1)\n score += num_j * 100 * (j + 1)\n num_tmp += num_j\n print("num_tmp:", num_tmp)\n\n if score >= G:\n num.append(num_tmp)\n print("num:", num)\n\nans = min(num)\nprint(ans)', 'D, G = map(int, input().split())\np = [0] * D\nc = [0] * D\nfor i in range(D):\n p[i], c[i] = map(int, input().split())\n\nnum = []\n\nfor i in range(2**D):\n score = 0\n num_tmp = 0 \n not_comp = [] \n for j in range(D):\n if i >> j & 1:\n score += p[j] * 100 * (j + 1) + c[j]\n num_tmp += p[j]\n else:\n not_comp.append(j)\n print("not_comp:", not_comp)\n\n for j in not_comp[::-1]:\n if score < G:\n num_j = min(p[j] - 1, (G - score) // (100 * (j + 1)))\n score += num_j * 100 * (j + 1)\n num_tmp += num_j\n print("num_tmp:", num_tmp)\n\n if score >= G:\n num.append(num_tmp)\n print("num:", num)\n\nans = min(num)\nprint(ans)', 'D, G = map(int, input().split())\np = [0] * D\nc = [0] * D\nfor i in range(D):\n p[i], c[i] = map(int, input().split())\n\nnum = []\n\nfor i in range(2**D):\n score = 0\n num_tmp = 0 \n not_comp = [] \n for j in range(D):\n if i >> j & 1:\n score += p[j] * 100 * (j + 1) + c[j]\n num_tmp += p[j]\n else:\n not_comp.append(j)\n\n for j in not_comp[::-1]:\n if score < G:\n num_j = min(p[j] - 1, (G - score) // (100 * (j + 1)))\n score += num_j * 100 * (j + 1)\n num_tmp += num_j\n\n if score >= G:\n num.append(num_tmp)\n\nans = min(num)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s120839987', 's904881377', 's508445774']
[5748.0, 5748.0, 3064.0]
[69.0, 71.0, 27.0]
[821, 813, 726]
p03290
u732061897
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["import itertools\nD, G = map(int,input().split())\nplist = [ list( map(int ,input().split())) for i in range(D)]\n\nprint(plist)\n\nbit = [0,1]\n'''\n(0, 0, 0, 0, 0)\n(0, 0, 0, 0, 1)\n(0, 0, 0, 1, 0)\n(0, 0, 0, 1, 1)\n(0, 0, 1, 0, 0)\n(0, 0, 1, 0, 1)\n(0, 0, 1, 1, 0)\n(0, 0, 1, 1, 1)\n(0, 1, 0, 0, 0)\n(0, 1, 0, 0, 1)\n(0, 1, 0, 1, 0)\n(0, 1, 0, 1, 1)\n(0, 1, 1, 0, 0)\n(0, 1, 1, 0, 1)\n(0, 1, 1, 1, 0)\n(0, 1, 1, 1, 1)\n(1, 0, 0, 0, 0)\n(1, 0, 0, 0, 1)\n(1, 0, 0, 1, 0)\n(1, 0, 0, 1, 1)\n(1, 0, 1, 0, 0)\n(1, 0, 1, 0, 1)\n(1, 0, 1, 1, 0)\n(1, 0, 1, 1, 1)\n(1, 1, 0, 0, 0)\n(1, 1, 0, 0, 1)\n(1, 1, 0, 1, 0)\n(1, 1, 0, 1, 1)\n(1, 1, 1, 0, 0)\n(1, 1, 1, 0, 1)\n(1, 1, 1, 1, 0)\n(1, 1, 1, 1, 1)\n\n'''\nanswerList = []\nfor i in range(D):\n answerList.append([plist[i][0], 100* (i+1) + plist[i][1]])\n\n\nsolutionList = itertools.product(bit, repeat=D)\nresult = []\nfor solutionTupple in itertools.product(bit, repeat=D):\n tmp = [0,0]\n maxIndex = -1\n for i in range(D):\n if solutionTupple[i] == 1:\n tmp[0] += answerList[i][0]\n tmp[1] += answerList[i][1]\n if solutionTupple[i] == 0 :\n maxIndex = max(maxIndex,i)\n \n result.append(tmp)\n \n if maxIndex == -1:\n break\n for i in range(answerList[maxIndex][0]):\n a = tmp[0] + i + 1\n b = tmp[1] + (i + 1) * (i+1) * 100\n result.append([a,b])\nanswer = float('inf')\nfor r in result:\n if r[1] > G:\n answer = min(answer,r[0])\n \nprint(answer)", "import itertools\nD, G = map(int,input().split())\nplist = [ list( map(int ,input().split())) for i in range(D)]\n\n#print(plist)\n\nbit = [0,1]\n'''\n(0, 0, 0, 0, 0)\n(0, 0, 0, 0, 1)\n(0, 0, 0, 1, 0)\n(0, 0, 0, 1, 1)\n(0, 0, 1, 0, 0)\n(0, 0, 1, 0, 1)\n(0, 0, 1, 1, 0)\n(0, 0, 1, 1, 1)\n(0, 1, 0, 0, 0)\n(0, 1, 0, 0, 1)\n(0, 1, 0, 1, 0)\n(0, 1, 0, 1, 1)\n(0, 1, 1, 0, 0)\n(0, 1, 1, 0, 1)\n(0, 1, 1, 1, 0)\n(0, 1, 1, 1, 1)\n(1, 0, 0, 0, 0)\n(1, 0, 0, 0, 1)\n(1, 0, 0, 1, 0)\n(1, 0, 0, 1, 1)\n(1, 0, 1, 0, 0)\n(1, 0, 1, 0, 1)\n(1, 0, 1, 1, 0)\n(1, 0, 1, 1, 1)\n(1, 1, 0, 0, 0)\n(1, 1, 0, 0, 1)\n(1, 1, 0, 1, 0)\n(1, 1, 0, 1, 1)\n(1, 1, 1, 0, 0)\n(1, 1, 1, 0, 1)\n(1, 1, 1, 1, 0)\n(1, 1, 1, 1, 1)\n\n'''\nanswerList = []\nfor i in range(D):\n answerList.append([plist[i][0], 100 * (i+1) * plist[i][0] + plist[i][1]])\n\n\nsolutionList = itertools.product(bit, repeat=D)\nresult = []\n\nfor i,solutionTupple in enumerate(itertools.product(bit, repeat=D)):\n if i == 0:\n for j in range(answerList[D-1][0]-1):\n a = j + 1\n result.append([j+1, D * 100 * (j + 1)])\n continue\n\n tmp = [0,0]\n maxIndex = -1\n for i in range(D):\n if solutionTupple[i] == 1:\n tmp[0] += answerList[i][0]\n tmp[1] += answerList[i][1]\n if solutionTupple[i] == 0:\n maxIndex = max(maxIndex, i)\n\n result.append(tmp)\n #print(solutionTupple)\n\n if maxIndex == -1:\n break\n for i in range(answerList[maxIndex][0]-1):\n a = tmp[0] + i + 1\n b = tmp[1] + (i + 1) * (maxIndex+1) * 100\n result.append([a,b])\n#print(answerList)\n#print(result)\nanswer = float('inf')\nfor r in result:\n if r[1] >= G:\n answer = min(answer,r[0])\n\nprint(answer)\n"]
['Wrong Answer', 'Accepted']
['s873455337', 's109768577']
[20036.0, 19916.0]
[129.0, 126.0]
[1447, 1685]
p03290
u732870425
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['ans = 10000\nfor i in range(2**D):\n s = 0\n cnt = 0\n b = [0] * D\n \n \n for j in range(D):\n if (i >> j) & 1:\n s += 100 * (j + 1) * pc[j][0] + pc[j][1]\n cnt += pc[j][0]\n b[j] = 1\n\n \n flag1 = False\n flag2 = True\n if s < G:\n for k in range(D)[::-1]:\n if b[k] == 0:\n for x in range(pc[k][0]):\n s += 100 * (k + 1)\n cnt += 1\n if s >= G:\n flag1 = True\n break\n else:\n flag2 = False\n break\n if flag1:\n break\n\n if flag2:\n ans = min(ans, cnt)\n\n\nprint(ans)', 'D, G = map(int, input().split())\npc = [tuple(map(int, input().split())) for _ in range(D)]\n\nans = 10000\nfor i in range(2**D):\n s = 0\n cnt = 0\n b = [0] * D\n \n \n for j in range(D):\n if (i >> j) & 1:\n s += 100 * (j + 1) * pc[j][0] + pc[j][1]\n cnt += pc[j][0]\n b[j] = 1\n\n \n flag1 = False\n flag2 = True\n if s < G:\n for k in range(D)[::-1]:\n if b[k] == 0:\n for x in range(pc[k][0]):\n s += 100 * (k + 1)\n cnt += 1\n if s >= G:\n flag1 = True\n break\n else:\n flag2 = False\n break\n if flag1:\n break\n\n if flag2:\n ans = min(ans, cnt)\n\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s397853402', 's477894059']
[3064.0, 3064.0]
[17.0, 50.0]
[851, 943]
p03290
u734876600
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d,g = map(int,input().split())\npo = [0]\nco = [0]\nfor i in range(d):\n p,c = map(int,input().split())\n po.append(p)\n co.append(c)\n\n\n\n\n\n\n\ndef f(G,i):\n if i == 0:\n return float("inf")\n n = min(G//(i * 100),p[i])\n s = 100 * i * n \n if n == p[i]:\n s += c[i]\n if s < G:\n n += f(G-s,i-1)\n return min(n,f(G,i-1))\n\nprint(f(g,d))', 'd,g = map(int,input().split())\npo = [0]\nco = [0]\nfor i in range(d):\n p,c = map(int,input().split())\n po.append(p)\n co.append(c)\n\n\n\n\n\n\n\ndef f(G,i):\n if i == 0:\n return float("inf")\n n = min(G//(i * 100),po[i])\n s = 100 * i * n \n if n == po[i]:\n s += c[i]\n if s < G:\n n += f(G-s,i-1)\n return min(n,f(G,i-1))\n\nprint(f(g,d))', 'd,g = map(int,input().split())\npo = [0]\nco = [0]\nfor i in range(d):\n p,c = map(int,input().split())\n po.append(p)\n co.append(c)\n\n\n\n\n\n\n\ndef f(G,i):\n if i == 0:\n return float("inf")\n n = min(G//(i * 100),po[i])\n s = 100 * i * n \n if n == po[i]:\n s += co[i]\n if s < G:\n n += f(G-s,i-1)\n return min(n,f(G,i-1))\n\nprint(f(g,d))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s564255926', 's792999128', 's977672858']
[3316.0, 3064.0, 3064.0]
[21.0, 18.0, 19.0]
[800, 802, 803]
p03290
u747602774
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import itertools\n\nD,G = map(int,input().split())\npc = [list(map(int,input().split())) for i in range(D)]\nprint(pc)\n\nans = 10**5\n\nfor v in itertools.product([0,1],repeat=D):\n p = 0\n t = 0\n for i in range(D):\n if v[i] == 1:\n p += (i+1)*100*pc[i][0] + pc[i][1]\n t += pc[i][0]\n w = G-p\n if w > 0:\n for i in range(D):\n if v[i] == 0 and w <= (i+1)*100*(pc[i][0]-1):\n a = (i+1)*100\n tt = t+(w+a-1)//a\n ans = min(ans,tt)\n else:\n ans = min(ans,t)\nprint(ans)\n', 'D,G = map(int,input().split())\npc = [list(map(int,input().split())) for _ in range(D)]\n\n\nscr = [((i+1)*100)*pc[i][0]+pc[i][1] for i in range(D)]\n\nans = 10**10\nfor i in range(2**D):\n a = 0\n c = 0\n for j in range(D):\n if i>>j&1:\n a += scr[j]\n c += pc[j][0]\n if a < G:\n continue\n ans = min(ans,c)\n for j in range(D):\n if i>>j&1:\n a -= scr[j]\n c -= pc[j][0]\n if a >= G:\n continue\n t = (j+1)*100\n if (G-a+t-1)//t < pc[j][0]:\n ans = min(ans,c+(G-a+t-1)//t)\n a += scr[j]\n c += pc[j][0]\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s556921902', 's320546734']
[3064.0, 3188.0]
[23.0, 26.0]
[566, 702]
p03290
u750058957
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = map(int, input().split())\npc = [list(map(int,input().split())) for _ in range(D)]\n\nans = 1 << 29\nt = []\nfor bit in range(1<<D):\n score = 0\n f = 0\n \n for i in range(D):\n if bit & (1<<i):\n score += pc[i][0]*100*(i+1) + pc[i][1]\n f += pc[i][0]\n if score >= G: break\n \n nokori = []\n for j in range(D):\n if not (bit & (1<<j)):\n nokori.append(pc[j] + [j+1])\n nokori = list(reversed(nokori))\n for d in nokori:\n for x in range(d[0]):\n if score >= G: break\n score += 100*(d[2])\n f += 1\n if score >= G: break\n print(bin(bit),f)\n ans = min(ans,f)\nprint(ans)\n', 'D,G = map(int, input().split())\npc = [list(map(int,input().split())) for _ in range(D)]\n\nans = 1 << 29\nt = []\nfor bit in range(1<<D):\n score = 0\n f = 0\n \n for i in range(D):\n if bit & (1<<i):\n score += pc[i][0]*100*(i+1) + pc[i][1]\n f += pc[i][0]\n if score >= G: break\n \n nokori = []\n for j in range(D):\n if not (bit & (1<<j)):\n nokori.append(pc[j] + [j+1])\n nokori = list(reversed(nokori))\n for d in nokori:\n for x in range(d[0]):\n if score >= G: break\n score += 100*(d[2])\n f += 1\n if score >= G: break\n ans = min(ans,f)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s483086908', 's692392831']
[3272.0, 3064.0]
[152.0, 186.0]
[806, 784]
p03290
u763968347
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["D,G = list(map(int,input().split()))\nP = []\nC = []\n\nfor i in range(D):\n p,c = list(map(int,input().split()))\n P.append(p)\n C.append(c)\n\nfor c in range(2**D):\n score = 0\n solved = 0\n remain = []\n for i,b in enumerate(format(c,'b').zfill(D)):\n if b == '1':\n score += P[i]*100*(i+1) + C[i]\n solved += P[i]\n else:\n remain.append(i)\n if score < G:\n R = G - score\n j = remain[-1]\n if (P[j]-1)*(j+1)*100 < R:\n continue\n solved += (R//(100*(j+1)))\n ans = min(solved, ans)\n\nprint(ans)", "D,G = list(map(int,input().split()))\nP = []\nC = []\n\nfor i in range(D):\n p,c = list(map(int,input().split()))\n P.append(p)\n C.append(c)\n\nans = 10000\n\nfor c in range(2**D):\n score = 0\n solved = 0\n remain = []\n for i,b in enumerate(format(c,'b').zfill(D)):\n if b == '1':\n score += P[i]*100*(i+1) + C[i]\n solved += P[i]\n else:\n remain.append(i)\n if score < G:\n R = G - score\n j = remain[-1]\n if (P[j]-1)*(j+1)*100 < R:\n continue\n solved += -(-R//(100*(j+1)))\n ans = min(solved, ans)\n\nprint(ans)"]
['Runtime Error', 'Accepted']
['s800795302', 's510960337']
[3064.0, 3064.0]
[23.0, 24.0]
[588, 603]
p03290
u768256617
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["import sys \nsys.setrecursionlimit(10**6)\n\ndef dfs(i,sum,count,nokori):\n global ans\n if i==g:\n if sum<g:\n use=max(nokori)\n n=min(pc[n-1][1],-(-(g-sum)//100*use)\n count+=n\n sum+=n*100*use\n\n if sum>=g:\n ans=min(ans,count)\n\n else:\n dfs(i+1,sum,count,nokori)\n dfs(i+1,sum+pc[i][0]*100*(i+1)+pc[i][1],count+pc[i][0],nokori-(i+1))\n\nd,g=map(int,input().split())\npc=[list(map(int,input().split())) for i in range(d)]\nans=float('inf')\n\ndfs(0,0,0,set(range(1,d+1))\n\nprint(ans) ", "import sys \nsys.setrecursionlimit(10**8)\n\ndef dfs(i,sum,count,nokori):\n global ans\n if i==d:\n if sum<g:\n use=max(nokori)\n n=min(pc[use-1][0],-(-(g-sum)//(100*use)))\n count +=n\n sum +=n*100*use\n\n if sum>=g:\n ans=min(ans,count)\n\n else:\n dfs(i+1,sum,count,nokori)\n dfs(i+1,sum+pc[i][0]*100*(i+1)+pc[i][1],count+pc[i][0],nokori-{i+1})\n\nd,g=map(int,input().split())\npc=[list(map(int,input().split())) for i in range(d)]\nans=float('inf')\n\ndfs(0,0,0,set(range(1,d+1)))\n\nprint(ans) "]
['Runtime Error', 'Accepted']
['s727173141', 's102305235']
[2940.0, 3064.0]
[17.0, 20.0]
[507, 515]
p03290
u768496010
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d, g = map(int,input().split())\nplist = [list(map(int,input().split())) for i in range(d)]\n\nbasiclist = []\n\nproblem = []\n\nfor i in range(len(plist)):\n tmplist = [plist[i][0], (plist[i][0])*(i+1)*100+plist[i][1]]\n problem.append(plist[i][0])\n basiclist.append(tmplist)\n\n# print(basiclist)\n\nimport itertools\n\ncombs = []\n\nfor i in range(1, len(problem)+1):\n els = [list(x) for x in itertools.combinations(problem, i)]\n combs.extend(els)\n\n# print(combs)\n\nmincount = 2**10+1\n\nfor k in range (1, basiclist[-1][0]):\n if k*len(basiclist)*100 >= g:\n print(k)\n exit(0)\n\nfor comb in combs:\n remaininglist=[]\n for basic in basiclist:\n if basic[0] not in comb:\n remaininglist.append(basic[0])\n best_remaining_score = len(remaininglist)*100\n total_ps = 0\n for com in comb:\n tmp = 0\n for basic in basiclist:\n if com == basic[0]:\n if basic[1] > tmp:\n tmp = basic[1]\n total_ps += tmp\n # print(total_ps)\n if len(remaininglist) == 0:\n mincount = min(mincount, sum(comb))\n continue\n for i in range(remaininglist[-1]):\n if total_ps + best_remaining_score*i >= g:\n mincount = min(mincount, i + sum(comb))\n break\n\nprint(mincount)\n', 'd, g = map(int,input().split())\nplist = [list(map(int,input().split())) for i in range(d)]\n\n# map of {number of problems to achieve ps : ps}\nbasiclist = []\n\nfor i in range(len(plist)):\n tmplist = [plist[i][0], (plist[i][0])*(i+1)*100+plist[i][1]]\n # problem.append(plist[i][0])\n basiclist.append(tmplist)\n\n# combination of perfect score cases: ps0, ps1, ps2, ps0 + ps1, ...\nimport itertools\n\nproblem = [i for i in range(d)]\n\ncombs = []\n\nfor i in range(1, d+1):\n els = [list(x) for x in itertools.combinations(problem, i)]\n # print(els)\n combs.extend(els)\n\n\nmincount = 2**10+1\n\n# case without perfect score\nfor i in range (d):\n for j in range (1, basiclist[i][0]):\n if j*(i+1)*100 >= g:\n mincount = min(mincount, j)\n\n# case of with perfect score\nfor comb in combs:\n # find the best-valued question that is not in the combination\n best_remaining_num = -1\n for a in range(d):\n if a not in comb:\n best_remaining_num = max(a, best_remaining_num)\n best_remaining_score = (best_remaining_num+1)*100\n\n # total perfect score of the combination and attempts required to achieve the score\n total_ps = 0\n total_ps_count = 0\n for com in comb:\n total_ps += basiclist[com][1]\n total_ps_count += basiclist[com][0]\n\n if best_remaining_num == -1:\n mincount = min(mincount, total_ps_count)\n continue\n\n\n for i in range(basiclist[best_remaining_num][0]):\n if total_ps + best_remaining_score*i >= g:\n \n mincount = min(mincount, i + total_ps_count)\n # print(mincount)\n break\n\nprint(mincount)\n']
['Wrong Answer', 'Accepted']
['s590267569', 's094927310']
[3188.0, 3188.0]
[36.0, 36.0]
[1290, 1850]
p03290
u771167374
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['#abc104c All Green\n\n\ndef dfs(i, sum, count, rest):\n global ans\n if i == d:\n if sum < g:\n rest_max = max(rest)\n n = min(l[rest_max-1][0], -(-(g-sum)//(rest_max*100)))\n count += n\n sum += n * rest_max * 100\n if sum >= g:\n ans = min(ans, count)\n else :\n dfs(i+1, sum, count, rest) \n dfs(i+1, sum + l[i][0]*(i+1)*100, count + l[i][0], rest - {i+1}) \n\nd, g = map(int, input().split())\nl = [list((map(int, input().split()))) for _ in range(d)]\nans = float("inf")\ndfs(0, 0, 0, set(range(1, d+1)))\nprint(ans)\n\n', 'def dfs(i, sum, count, rest):\n global ans\n if i == d:\n if sum < g:\n rest_max = max(rest)\n n = min(l[rest_max-1][0], -(-(g-sum)//(rest_max*100)))\n count += n\n sum += n * rest_max * 100\n if sum >= g:\n ans = min(ans, count)\n else :\n dfs(i+1, sum, count, rest) \n dfs(i+1, sum + l[i][0]*(i+1)*100+l[i][1], count + l[i][0], rest - {i+1}) \n\nd, g = map(int, input().split())\nl = [list((map(int, input().split()))) for _ in range(d)]\nans = float("inf")\ndfs(0, 0, 0, set(range(1, d+1)))\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s177653607', 's565065867']
[9120.0, 9140.0]
[29.0, 34.0]
[754, 630]
p03290
u781262926
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["import sys\nfrom math import ceil\ninputs = sys.stdin.readlines()\n\nd, g = map(int, inputs[0].split())\nP = list(map(int, map(lambda x: x.split()[0], inputs[1:])))\nC = list(map(int, map(lambda x: x.split()[1], inputs[1:])))\n\nans = float('inf')\nfor bit in range(1 << d):\n count, total, rest = 0, 0, set(range(1, d+1))\n for i in range(d):\n if bit & (1 << i):\n total += P[i] * (i + 1) * 100 + C[i]\n count += P[i]\n rest.discard(i + 1)\n\n if total < g:\n use = max(rest)\n\n# count += n\n\n n = ceil((g - total) / (use * 100))\n if P[use-1] > n:\n count += n\n total += n * use * 100\n ans = min(ans, count)\n# if total >= g:\n# ans = min(ans, count)\nprint(ans) \n\n", "d, g = map(int, inputs[0].split())\nP = list(map(int, map(lambda x: x.split()[0], inputs[1:])))\nC = list(map(int, map(lambda x: x.split()[1], inputs[1:])))\n\nans = float('inf')\nfor bit in range(1 << d):\n count, total, rest = 0, 0, set(range(1, d+1))\n for i in range(d):\n if bit & (1 << i):\n total += P[i] * (i + 1) * 100 + C[i]\n count += P[i]\n rest.discard(i + 1)\n\n if total < g:\n use = max(rest)\n n = ceil((g - total) / (use * 100))\n if P[use-1]-1 < n:\n continue\n count += n\n total += n * use * 100\n \n if total >= g:\n ans = min(ans, count)\nprint(ans) \n", "import sys\nfrom math import ceil\ninputs = sys.stdin.readlines()\n\nd, g = map(int, inputs[0].split())\nP = list(map(int, map(lambda x: x.split()[0], inputs[1:])))\nC = list(map(int, map(lambda x: x.split()[1], inputs[1:])))\n\nans = float('inf')\nfor bit in range(1 << d):\n count, total, rest = 0, 0, set(range(1, d+1))\n for i in range(d):\n if bit & (1 << i):\n total += P[i] * (i + 1) * 100 + C[i]\n count += P[i]\n rest.discard(i + 1)\n\n if total < g:\n use = max(rest)\n n = ceil((g - total) / (use * 100))\n if P[use-1]-1 < n:\n continue\n count += n\n total += n * use * 100\n \n if total >= g:\n ans = min(ans, count)\nprint(ans) \n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s199808536', 's232956488', 's765185324']
[3192.0, 3064.0, 3064.0]
[24.0, 18.0, 24.0]
[858, 663, 728]
p03290
u782098901
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = map(int, input().split())\nPC = [tuple(map(int, input().split()))]\n\nres = float("inf")\nfor bit in range(1 << D):\n sum = 0\n num = 0\n for i in range(D):\n if ((bit >> i) & 1):\n sum += (i + 1) * 100 * P[i] + C[i]\n num += P[i]\n if sum >= G:\n res = min(res, num)\n for i in range(D - 1, -1, -1):\n if ((bit >> i) & 1):\n continue\n for j in range(P[i] - 1):\n sum += (i + 1) * 100\n num + +\n if sum >= G:\n res = min(res, num)\n break\n print(res)\n', 'D, G = map(int, input().split())\nPC = [tuple(map(int, input().split())) for _ in range(D)]\n\nres = float("inf")\nfor bit in range(1 << D):\n summ = 0\n num = 0\n for i in range(D):\n if ((bit >> i) & 1):\n summ += (i + 1) * 100 * PC[i][0] + PC[i][1]\n num += PC[i][0]\n if summ >= G:\n res = min(res, num)\n for i in range(D - 1, -1, -1):\n if ((bit >> i) & 1):\n continue\n for _ in range(PC[i][0] - 1):\n summ += (i + 1) * 100\n num += 1\n if summ >= G:\n res = min(res, num)\n break\nprint(res)\n']
['Runtime Error', 'Accepted']
['s229170329', 's841291426']
[3064.0, 3064.0]
[17.0, 143.0]
[569, 617]
p03290
u797994565
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["d,g = input().split(' ')\nd,g = int(d),int(g)\n\n\ndef argmax(x):\n\tmax_value = -1000000000\n\tindex = 0\n\tfor i,e in enumerate(x):\n\t\tif max_value < e:\n\t\t\tindex = i\n\treturn i\n\ndef compute(point,prob_num,bonus_point):\n\treturn point*prob_num + bonus_point\n\n\npoint_list=[input().split(' ') for i in range(d)]\npoint_list = [[int(e) for e in point] for point in point_list]\nefficiency = [((i+1)*100.*point[0]+ point[1])/point[0] for i,point in enumerate(point_list)]\n\ncount = 0\n\nwhile g > 0:\n\tindex = argmax(efficiency)\n\telement = point_list[index]\n\telement_point = compute((index+1)*100,element[0],element[1])\n\ttmp_g = g\n\tif g - element_point < -100:\n\t\tfor i in range(element[0]-1):\n\t\t\ttmp_g -= (index+1)*100\n\t\t\tif tmp_g <= 0:\n\t\t\t\tcount += i+1\n\t\t\t\tprint(count)\n\t\t\t\texit()\n\t\ttmp_g -= (index+1)*100\n\t\ttmp_g -= element[1]\n\t\tcount += element[0]\n\t\tif tmp_g <= 0:\n\t\t\tprint(count)\n\t\t\texit()\n\telif g - element_point == 0:\n\t\tcount += element[0]\n\t\tprint(count)\n\t\texit()\t\t\n\telse:\n\t\tcount += element[0]\n\t\tg -= element_point\n\t\tdel(point_list[index])\n\t\tdel(efficiency[index])\nprint(count)\n\n", "def argmax(x):\n\tmax_value = -1000000000\n\tindex = 0\n\tfor i,e in enumerate(x):\n\t\tif max_value < e:\n\t\t\tindex = i\n\treturn i\n\ndef compute(point,prob_num,bonus_point):\n\treturn point*prob_num + bonus_point\n\n\nd,g = input().split(' ')\nd,g = int(d),int(g)\n\npoint_list=[input().split(' ') for i in range(d)]\npoint_list = [[int(e) for e in point] for point in point_list]\nefficiency = [((i+1)*100.*point[0]+ point[1])/point[0] for i,point in enumerate(point_list)]\npoints = [i*100 for i in range(1,d+1)]\ncount = 0\n\nwhile g > 0:\n\tindex = argmax(efficiency)\n\telement = point_list[index]\n\telement_point = compute((index+1)*100,element[0],element[1])\n\ttmp_g = g\n\tif g - element_point <= -100:\n\t\tfor i in range(point_list[-1][0]-1):\n\t\t\ttmp_g -= points[-1]*100\n\t\t\tif tmp_g <= 0:\n\t\t\t\tcount += i+1\n\t\t\t\tprint(count)\n\t\t\t\texit()\n\t\ttmp_g -= points[-1]*100\n\t\ttmp_g -= element[1]\n\t\tcount += element[0]\n\t\tif tmp_g <= 0:\n\t\t\tprint(count)\n\t\t\texit()\n\telif g - element_point == 0:\n\t\tcount += element[0]\n\t\tprint(count)\n\t\texit()\t\t\n\telse:\n\t\tcount += element[0]\n\t\tg -= element_point\n\t\tdel(point_list[index])\n\t\tdel(efficiency[index])\n\t\tdel(points[index])\nprint(count)\n\n", "def argmax(x):\n\tmax_value = -1000000000\n\tindex = 0\n\tfor i,e in enumerate(x):\n\t\tif max_value < e:\n\t\t\tindex = i\n\treturn i\n\ndef compute(point,prob_num,bonus_point):\n\treturn point*prob_num + bonus_point\n\n\nd,g = input().split(' ')\nd,g = int(d),int(g)\n\npoint_list=[input().split(' ') for i in range(d)]\npoint_list = [[int(e) for e in point] for point in point_list]\nefficiency = [((i+1)*100.*point[0]+ point[1])/point[0] for i,point in enumerate(point_list)]\n\ncount = 0\n\nwhile g > 0:\n\tindex = argmax(efficiency)\n\telement = point_list[index]\n\telement_point = compute((index+1)*100,element[0],element[1])\n\ttmp_g = g\n\tif g - element_point <= -100:\n\t\tfor i in range(element[0]-1):\n\t\t\ttmp_g -= (index+1)*100\n\t\t\tif tmp_g <= 0:\n\t\t\t\tcount += i+1\n\t\t\t\tprint(count)\n\t\t\t\texit()\n\t\ttmp_g -= (index+1)*100\n\t\ttmp_g -= element[1]\n\t\tcount += element[0]\n\t\tif tmp_g <= 0:\n\t\t\tprint(count)\n\t\t\texit()\n\telif g - element_point == 0:\n\t\tcount += element[0]\n\t\tprint(count)\n\t\texit()\t\t\n\telse:\n\t\tcount += element[0]\n\t\tg -= element_point\n\t\tdel(point_list[index])\n\t\tdel(efficiency[index])\nprint(count)\n\n", "D, G = map(int, input().split())\nQ = []\nfor i in range(D):\n p, c = map(int, input().split())\n Q.append([p, c,(i+1)*100])\nans = 10**18\nfor i in range(2**D):\n state = format(i,'0%ib'%(D))\n value = 0\n count = 0\n for s,(p,c,v) in zip(state,Q):\n if s == '1':\n value += p*v + c\n count += p\n if value >= G:\n ans = min(ans,count)\n else:\n for s,(p,c,v) in zip(reversed(state),reversed(Q)):\n if s == '1':\n continue\n if (G-value) > v*(p-1):\n value += v*(p-1)\n count += p-1\n else:\n if (G-value)%v == 0:\n c = (G-value)//v\n else:\n c = int((G-value)/v)+1\n value += v*c\n count += c\n ans = min(ans,count)\n break\nprint(ans)"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s173621186', 's391526220', 's671430299', 's936759047']
[3064.0, 3064.0, 3064.0, 3064.0]
[17.0, 18.0, 18.0, 27.0]
[1064, 1132, 1064, 878]
p03290
u813098295
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["D, G = map(int, input().split())\nP, C = [], []\n\nfor _ in range(D):\n p, c = map(int, input().split())\n P.append(p); C.append(c)\n\nans = float('inf')\n\nfor bit in range(2**D):\n score, solve_num = 0, 0\n for i in range(D):\n if (bit >> i) & 1:\n score += (100 * (i+1) * P[i] + C[i])\n solve_num += P[i]\n is_solve[i] += P[i]\n\n for i in range(D-1, -1, -1):\n if score >= G:\n break\n\n if (bit >> i) & 1:\n continue\n\n for j in range(p[i]):\n score += 100*(i+1)\n solve_num += 1\n\n if score >= G:\n break\n\n ans = min(ans, solve_num)\n\nprint(ans)\n", "D, G = map(int, input().split())\nP, C = [], []\n\nfor _ in range(D):\n p, c = map(int, input().split())\n P.append(p); C.append(c)\n\nans = float('inf')\n\nfor bit in range(2**D):\n score, solve_num = 0, 0\n for i in range(D):\n if (bit >> i) & 1:\n score += (100 * (i+1) * P[i] + C[i])\n solve_num += P[i]\n is_solve[i] += P[i]\n\n for i in range(D-1, -1, -1):\n if score >= G:\n break\n\n if (bit >> i) & 1:\n continue\n\n for j in range(P[i]):\n score += 100*(i+1)\n solve_num += 1\n\n if score >= G:\n break\n\n ans = min(ans, solve_num)\n\nprint(ans)", "D, G = map(int, input().split())\nP, C = [], []\n\nfor _ in range(D):\n p, c = map(int, input().split())\n P.append(p); C.append(c)\n\nans = float('inf')\n\nfor bit in range(2**D):\n score, solve_num = 0, 0\n\n for i in range(D):\n if (bit >> i) & 1:\n score += (100 * (i+1) * P[i] + C[i])\n solve_num += P[i]\n\n for i in range(D-1, -1, -1):\n if score >= G:\n break\n\n if (bit >> i) & 1:\n continue\n\n for j in range(P[i]):\n score += 100*(i+1)\n solve_num += 1\n\n if score >= G:\n break\n\n ans = min(ans, solve_num)\n\nprint(ans)\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s524335732', 's833342530', 's761467007']
[3064.0, 3064.0, 3064.0]
[17.0, 19.0, 158.0]
[673, 672, 642]
p03290
u814781830
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['def add(pc, p, G, tmp):\n b = False\n for i in range(len(pc)-1, -1, -1):\n for k in range(pc[i][0]):\n p += (i+1) * 100\n tmp += 1\n if p >= G:\n return tmp\n\n\nD, G = map(int,input().split())\npc = [list(map(int,input().split())) for i in range(D)]\ncnt = 0\ntmp = 0\n\nfor i in range(D):\n p = (i+1) * 100 * pc[i][0]\n p += pc[i][1]\n tmp = pc[i][0]\n while p < G:\n tmp += add(pc, p, G, tmp)\n cnt = min(cnt, tmp)\nprint(cnt)\n', 'D, G = map(int, input().split())\npc = [list(map(int, input().split())) for _ in range(D)]\n\ndef dfs(question_num, rquired_point):\n if question_num < 0:\n return 10 ** 9\n\n point = (question_num+1) * 100\n ans_num = min(rquired_point // point, pc[question_num][0])\n score = ans_num * point\n\n if ans_num == pc[question_num][0]:\n score += pc[question_num][1]\n\n if rquired_point > score:\n ans_num += dfs(question_num-1, rquired_point-score)\n \n return min(ans_num, dfs(question_num-1, rquired_point))\n\nprint(dfs(D-1, G))']
['Runtime Error', 'Accepted']
['s622421210', 's251067883']
[3064.0, 3064.0]
[2104.0, 18.0]
[491, 556]
p03290
u821775079
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d,g=[int(_) for _ in input().split()]\nl=[0]+[list(map(int,input().split())) for _ in range(d)]\nprint(l)\ndef f(i,g):\n\tif i==0:return 10**9\n\tc=min(g//(100*i),l[i][0])\n\ts=100*i*c\n\tif c==l[i][0]:s+=l[i][1]\n\tif s<g:\n\t\tc+=f(i-1,g-s)\n\treturn min(c,f(i-1,g))\nprint(f(d,g))', 'import sys\nsys.setrecursionlimit(10 ** 6)\n\nD,G=map(int,input().split())\np=[]\nc=[]\nfor i in range(D):\n a,b=map(int,input().split())\n p += [a]\n c += [b]\n\ndef solve(bit):\n if bit >= (1<<D):\n return 1000\n p_sum=0\n num=0\n for i in range(D):\n if bit & (1<<i):\n p_sum += c[i] + p[i] * 100*(i+1)\n num += p[i]\n if p_sum >= G:\n return min(num,solve(bit+1))\n else:\n for i in reversed(range(D)):\n if bit & 1<<i:\n continue\n for j in range(p[i]):\n if p_sum >= G:\n break\n p_sum += 100*(i+1)\n num += 1\n else:\n return solve(bit+1)\n return min(num,solve(bit+1))\n\nprint(solve(0))']
['Wrong Answer', 'Accepted']
['s146452226', 's445348915']
[9232.0, 9900.0]
[33.0, 39.0]
[265, 653]
p03290
u840974625
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['n, g = map(int, input().split())\nList = [list(map(int, input().split())) for i in range(n)]\n\nans = 0\na = 0\nres = 0\n\nmax_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] \nscore = [(i+1)*100 for i in range(n-1, -1, -1)] \nhowmany = [List[i][0] for i in range(n-1, -1, -1)]\n\nwhile(ans + max_score[a] <= g):\n ans += max_score[a]\n a += 1\n\nfor i in range(a):\n res += howmany[i]\n \nrest = g - ans\nx = -(-rest // score[a])\n \n#print(max_score)\n#print(score)\n#print(howmany)\n#print(res)\nprint(res + x)', 'n, g = map(int, input().split())\nList = [list(map(int, input().split())) for i in range(n)]\n\nans = []\n\nmax_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] \nscore = [(i+1)*100 for i in range(n-1, -1, -1)] \nhowmany = [List[i][0] for i in range(n-1, -1, -1)] \n\nfor i in range(2**n):\n s = 0\n m = 0\n max = 0 \n for j in range(n):\n if((i >> j) & 1):\n max += 1\n s += max_score[j]\n m += howmany[j]\n if(s >= g):\n ans.append(m)\n else:\n if(max < n):\n print(m)\n rest = g - s\n k = rest // score[max] \n if(k < howmany[max]):\n m += k\n ans.append(m)\n \nprint(ans)\nprint(min(ans))', 'n, g = map(int, input().split())\nList = [list(map(int, input().split())) for i in range(n)]\n\npre_ans = 0\nans = 0\na = 0\nres = 0\nx = 0\n\nmax_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] \nscore = [(i+1)*100 for i in range(n-1, -1, -1)] \nhowmany = [List[i][0] for i in range(n-1, -1, -1)] \n\nwhile(ans <= g):\n pre_ans = ans\n ans += max_score[a]\n a += 1\n \nfor i in range(a):\n res += howmany[i]\n \nrest = g - ans\n#x = -(-rest // score[a])\nif rest > 0:\n x = rest // score[a]\n\n#print(max_score)\n#print(score)\n#print(howmany)\n#print(res)\n#print(x)\nprint(res + x)', 'n, g = map(int, input().split())\nList = [list(map(int, input().split())) for i in rage(n)]\n\nans = 0\na = 0\nres = 0\n\nmax_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] \nscore = [(i+1)*100 for i in range(n-1, -1, -1)] \n\nwhile(ans + max_score[a] <= g):\n ans += max_score[a]\n a += 1\n\nfor i in range(a):\n res += List[n - a][0]\n \nrest = g - ans\nx = -(-rest // score[a])\n \nprint(res + x)', 'n, g = map(int, input().split())\nList = [list(map(int, input().split())) for i in range(n)]\n\nans = 0\na = 0\nres = 0\n\nmax_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] \nscore = [(i+1)*100 for i in range(n-1, -1, -1)] \n\nwhile(ans + max_score[a] <= g):\n ans += max_score[a]\n a += 1\n\nfor i in range(a):\n res += List[n - a][0]\n \nrest = g - ans\nx = -(-rest // score[a])\n \nprint(res + x)', 'n, g = map(int, input().split())\nList = [list(map(int, input().split())) for i in range(n)]\n\nans = []\n\nmax_score = [(i+1)*100*List[i][0]+List[i][1] for i in range(n-1, -1, -1)] \nscore = [(i+1)*100 for i in range(n-1, -1, -1)] \nhowmany = [List[i][0] for i in range(n-1, -1, -1)] \n\nfor i in range(2**n):\n s = 0\n m = 0\n max = 0 \n for j in range(n):\n if((i >> j) & 1):\n max += 1\n s += max_score[j]\n m += howmany[j]\n if(s >= g):\n ans.append(m)\n else:\n if(max < n):\n rest = g - s\n k = -(-rest // score[max]) \n if(k < howmany[max]):\n m += k\n ans.append(m)\n\nprint(min(ans))']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s041236156', 's341183557', 's551409536', 's850947293', 's910866770', 's414619385']
[3064.0, 3188.0, 3064.0, 3064.0, 3064.0, 3064.0]
[17.0, 22.0, 17.0, 17.0, 17.0, 21.0]
[627, 982, 732, 503, 504, 946]
p03290
u841531687
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = map(int,input().split())\nl = list(list(map(int, input().split())) for _ in range(D))\n\n\nl = l[::-1]\n\nans = float("inf")\nfor i in range(2**D):\n total = 0\n cnt = 0\n for j in range(D):\n \n if (i>>j)&1:\n total += 100*(D-j)*l[j][0] + l[j][1]\n cnt += l[j][0]\n if total >= G:\n ans = min(ans,cnt)\n continue\n for j in range(D):\n if (i>>j)&1 == False:\n for k in range(l[j][0]):\n total += 100*(D-j)\n cnt+=1\n if total >= G:\n ans = min(ans,cnt)\n break\n break\n\nprint(ans)', 'D,G = map(int,input().split())\nl = list(list(map(int, input().split())) for _ in range(D))\n\n\nl = l[::-1]\n\nans = float("inf")\nfor i in range(2**D):\n total = 0\n cnt = 0\n for j in range(D):\n if (i>>j)&1:\n total += 100*(D-j)*l[j][0] + l[j][1]\n cnt += l[j][0]\n if total >= G:\n ans = min(ans,cnt)\n continue\n for j in range(D):\n if (i>>j)&1 == False:\n for k in range(l[j][0]):\n total += 100*(D-j)\n cnt+=1\n if total >= G:\n ans = min(ans,cnt)\n break\n #break\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s440218843', 's421325854']
[2940.0, 3064.0]
[17.0, 156.0]
[678, 676]
p03290
u842243706
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["def main():\n\tD,G = map(int,input().split())\n\tListPC = [list(map(int,input().split())) for d in range(D)]\n\tans = sum([i[0] for i in ListPC])\n\n\tfor i in range(2**D):\n\t\tTempPoint,num,restmax = 0,0,-1 \n\t\tfor j in range(D): \n\t\t\tif i>>j & 1:\n\t\t\t\tTempPoint += 100*(j+1)*ListPC[j][0]+ListPC[j][1]\n\t\t\t\tnum += ListPC[j][0]\n\t\t\telse:\n\t\t\t\trestmax = max(j,restmax)\n\t\tif TempPoint >= G: \n\t\t\tans = min(num,ans)\n\t\telif G - TempPoint // ((restmax + 1) * 100) <= ListPC[restmax][0]: \n\t\t\tans = min(num + (G - TempPoint - 1) // ((restmax + 1) * 100) + 1, ans)\n\t\tprint(ans)\n\nif __name__ == '__main__':\n\tmain()", "def main():\n\tD,G = map(int,input().split())\n\tListPC = [list(map(int,input().split())) for d in range(D)]\n\tans = sum([i[0] for i in ListPC])\n\n\tfor i in range(2**D):\n\t\t\n\t\tTempPoint,num,restmax = 0,0,-1\n\t\t\n\t\tfor j in range(D):\n\t\t\tif i>>j & 1:\n\t\t\t\tTempPoint += 100*(j+1)*ListPC[j][0]+ListPC[j][1]\n\t\t\t\tnum += ListPC[j][0]\n\t\t\telse:\n\t\t\t\trestmax = max(j,restmax)\n\t\t\n\t\tif TempPoint >= G:\n\t\t\tans = min(num,ans)\n\t\t\n\t\telif (G - TempPoint) // ((restmax + 1) * 100) <= ListPC[restmax][0]:\n\t\t\tans = min(num + (G - TempPoint - 1) // ((restmax + 1) * 100) + 1, ans)\n\tprint(ans)\n\nif __name__ == '__main__':\n\tmain()"]
['Wrong Answer', 'Accepted']
['s573683606', 's004340759']
[9228.0, 9100.0]
[31.0, 32.0]
[722, 729]
p03290
u842964692
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['from itertools import product\n\nD,G=map(int,input().split())\np,c=[],[]\n\nfor _ in range(D):\n pi,ci=map(int,input().split())\n p.append(pi)\n c.append(ci)\n \nans=10**4\n \nfor cpls in product(range(2),repeat=D):\n num=0\n tensu=0\n for i,v in enumerate(cpls,start=1):\n if v==1:\n tensu+=i*100*p[i-1]+c[i-1]\n num+=p[i-1]\n if tensu>=G:\n ans=min(ans,num)\n continue\n for i,v in reversed(list(enumerate(cpls,start=1))):\n if v==0:\n for j in range(1,p[i-1]):\n tensu+=j*100*p[i-1]\n num+=1\n if tensu>=G:\n ans=min(ans,num)\n break\nprint(ans)\n \n \n \n\n', 'from itertools import product\n\nD,G=map(int,input().split())\np,c=[],[]\n\nfor _ in range(D):\n pi,ci=map(int,input().split())\n p.append(pi)\n c.append(ci)\n \nans=10**4\n \nfor cpls in product((range(2),repeat=D)):\n num=0\n tensu=0\n for i,v in enumerate(cpls,start=1):\n if v==1:\n tensu+=i*100*p[i-1]+c[i-1]\n num+=p[i-1]\n if tensu>=G:\n ans=min(ans,num)\n continue\n for i,v in reversed(list(enumerate(cpls,start=1))):\n if v==0:\n for j in range(1,p[i-1]):\n tesu+=j*100*p[i-1]\n num+=1\n if tensu>=G:\n ans=min(ans,num)\n break\nprint(ans)\n \n \n \n', 'from intetools import product\n\nD,G=map(int,input().split())\np,c=[],[]\n\nfor _ in range(D):\n pi,ci=map(int,input().split())\n p.append(pi)\n c.append(ci)\n \nans=10**4\n \nfor cpls in product((range(2),repeat=D)):\n num=0\n tensu=0\n for i,v in enumerate(cpls,start=1):\n if v==1:\n tensu+=i*100*p[i-1]+c[i-1]\n num+=p[i-1]\n if tensu>=G:\n ans=min(ans,num)\n continue\n for i,v in reversed(list(enumerate(cpls,start=1))):\n if v==0:\n for j in range(1,p[i-1]):\n tesu+=j*100*p[i-1]\n num+=1\n if tensu>=G:\n ans=min(ans,num)\n break\nprint(ans)\n \n \n ', 'from intertools import product\n\nD,G=map(int,input().split())\np,c=[],[]\n\nfor _ in range(D):\n pi,ci=map(int,input().split())\n p.append(pi)\n c.append(ci)\n \nans=10**4\n \nfor cpls in product((range(2),repeat=D)):\n num=0\n tensu=0\n for i,v in enumerate(cpls,start=1):\n if v==1:\n tensu+=i*100*p[i-1]+c[i-1]\n num+=p[i-1]\n if tensu>=G:\n ans=min(ans,num)\n continue\n for i,v in reversed(list(enumerate(cpls,start=1))):\n if v==0:\n for j in range(1,p[i-1]):\n tesu+=j*100*p[i-1]\n num+=1\n if tensu>=G:\n ans=min(ans,num)\n break\nprint(ans)\n \n \n \n', 'from itertools import product\n\nD,G=map(int,input().split())\np,c=[],[]\n\nfor _ in range(D):\n pi,ci=map(int,input().split())\n p.append(pi)\n c.append(ci)\n \nans=10**4\n \nfor cpls in product(range(2),repeat=D):\n num=0\n tensu=0\n for i,v in enumerate(cpls,start=1):\n if v==1:\n tensu+=i*100*p[i-1]+c[i-1]\n num+=p[i-1]\n if tensu>=G:\n ans=min(ans,num)\n continue\n for i,v in reversed(list(enumerate(cpls,start=1))):\n if v==0:\n for _ in range(p[i-1]-1):\n tensu+=100*i\n num+=1\n if tensu>=G:\n ans=min(ans,num)\n break\nprint(ans)\n \n \n \n\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s015910715', 's069511514', 's175533730', 's824225889', 's906041278']
[3064.0, 2940.0, 2940.0, 3064.0, 3064.0]
[40.0, 17.0, 17.0, 17.0, 139.0]
[636, 636, 635, 637, 629]
p03290
u844005364
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['difficulties, goal = map(int, input().split())\n\npcs = [list(map(int, input().split())) for _ in range(difficulties)]\n\ntotal_problem = 0\nnew_dp = [0] * 1001\n\nfor d, pc in enumerate(pcs, 1):\n dp = new_dp\n\n problem, complete = pc\n total_problem += problem\n\n score = {x: x*100*d for x in range(problem)}\n score[problem] = problem * 100 * d +complete\n\n for i in range(1, total_problem + 1):\n for j in range(0, i + 1):\n if i - j > problem:\n continue\n else:\n new_dp[i] = max(new_dp[i], dp[d-1][j] + score[i-j])\n\nfor i, a in enumerate(new_dp):\n if a >= goal:\n print(i)\n exit()\n', 'difficulties, goal = map(int, input().split())\n\npcs = [list(map(int, input().split())) for _ in range(difficulties)]\n\ntotal_problem = 0\nnew_dp = [0] * 1001\n\nfor d, pc in enumerate(pcs, 1):\n dp = new_dp[:]\n\n problem, complete = pc\n total_problem += problem\n\n score = {x: x*100*d for x in range(problem)}\n score[problem] = problem * 100 * d +complete\n\n for i in range(1, total_problem + 1):\n for j in range(0, i + 1):\n if i - j > problem:\n continue\n else:\n new_dp[i] = max(new_dp[i], dp[j] + score[i-j])\n\nfor i, a in enumerate(new_dp):\n if a >= goal:\n print(i)\n exit()\n']
['Runtime Error', 'Accepted']
['s451200061', 's738223701']
[3064.0, 3064.0]
[19.0, 443.0]
[663, 661]
p03290
u844789719
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import itertools\nD, G = [int(_) for _ in input().split()]\nSPC = [[100 * (i + 1)] + [int(_) for _ in input().split()] for i in range(D)]\nans = 10000\nfor flags in itertools.product([0, 1], repeat = D):\n print(flags)\n score = G\n count = 0\n for i in range(D):\n if flags[i]:\n score -= SPC[i][0] * SPC[i][1] + SPC[i][2]\n count += SPC[i][1]\n if score > 0:\n for i in range(D):\n count_res = 100\n if not flags[i] or SPC[i][0] * (SPC[i][1] - 1) < score:\n count_res = min(count_res, score // SPC[i][0] + 1)\n if count_res == 100:\n continue\n else:\n count += count_res\n ans = min(ans, count)\nprint(ans)', 'import itertools\nD, G = [int(_) for _ in input().split()]\nSPC = [[100 * (i + 1)] + [int(_) for _ in input().split()]\n for i in range(D)][::-1]\nans = 10**10\nfor i in range(D + 1):\n completes = set(itertools.combinations(range(D), i))\n for complete in completes:\n incomplete = sorted(set(range(D)) - set(complete))\n score = 0\n cnt = 0\n f = 0\n for j in complete:\n s, p, c = SPC[j]\n score += s * p + c\n cnt += p\n for j in incomplete:\n if score >= G:\n break\n s, p, c = SPC[j]\n d = min(p - 1, 1 + (G - score - 1) // s)\n score += s * d\n cnt += d\n if score >= G:\n ans = min(ans, cnt)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s869022368', 's753066747']
[3188.0, 9132.0]
[30.0, 35.0]
[714, 762]
p03290
u853952087
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G=list(map(int, input().split()))\n\nL=[0]+[list(map(int, input().split())) for i in range(D)]\n\ndef f(G, i):\n l=[]\n a=1000\n if i==0:\n return 1000\n else:\n j=min(G//(i*100), L[i][0])\n g=G-j*i*100 \n if j==L[i][0] and g-L[i][1]>0:\n a=min(a,f(g-L[i][1],i-1)+j)\n elif j==L[i][0] and g-L[i][1]<=0:\n a=min(a,L[i][0])\n elif g>0:\n a=min(f(g,i-1)+j,a)\n elif g<=0:\n a=min(a,j)\n return a\nprint(f(G,D))', 'D, G=list(map(int, input().split()))\n\nL=[0]+[list(map(int, input().split())) for i in range(D)]\n \n\ndef f(G, i):\n if i==0:\n\t return 10000\n \n n=min(G//(i*100), L[i][0])\n \n s=n*i*100\n \n if n==L[i][0]:\n s+=L[i][1]\n\t\n if s<G:\n n+=f(G-s, i-1)\n \n return min(n, f(G,i-1))\nprint(f(G, D))']
['Wrong Answer', 'Accepted']
['s768771444', 's643973373']
[3064.0, 3064.0]
[17.0, 18.0]
[655, 740]
p03290
u856364553
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = [int(i) for i in input().split()]\n\np = []\nc = []\nfor i in range(D):\n tmp = [int(i) for i in input().split()]\n p.append(int(tmp[0]))\n c.append(int(tmp[1]))\n\ndef AccuracyQestionNum(acc_list, count):\n counter = count\n for i in range(len(acc_list)):\n if acc_list[i] == 1:\n counter += p[i]\n return counter\n\ndef MaxScoreIndex(acc_list):\n for i in reversed(range(len(acc_list))):\n if acc_list[i] == 0:\n return i\n \ndef FinalQestionNum(acc_list, score):\n remain_point = G - score\n counter = 0\n max_score_index = MaxScoreIndex(acc_list)\n for i in range(p[max_score_index]):\n remain_point -= (max_score_index+1) * 100\n counter += 1\n if remain_point <= 0:\n break\n\n if counter == p[max_score_index]:\n return None\n else:\n return counter\n \ndef ScoreCalculation(acc_list):\n score = 0\n for i in range(len(acc_list)):\n if acc_list[i] == 1:\n score += (i+1) * 100 * p[i]\n score += c[i]\n return score\n\ndef DFSQestion(acc_list):\n \n if len(acc_list) == D:\n score = ScoreCalculation(acc_list)\n if score >= G:\n question_num = AccuracyQestionNum(acc_list, 0)\n print(acc_list, 0)\n else:\n count = FinalQestionNum(acc_list, score)\n if count == None:\n return None\n else:\n question_num = AccuracyQestionNum(acc_list, count)\n return question_num\n else:\n question_num1 = DFSQestion(acc_list + [0])\n question_num2 = DFSQestion(acc_list + [1])\n if question_num1 == None:\n return question_num2\n if question_num2 == None:\n return question_num1\n if question_num1 >= question_num2:\n return question_num2\n else:\n return question_num1\n \nquestion_num = DFSQestion([])\n\nprint(question_num)\n\n\n\n', 'D, G = [int(i) for i in input().split()]\n\np = []\nc = []\nfor i in range(D):\n tmp = [int(i) for i in input().split()]\n p.append(int(tmp[0]))\n c.append(int(tmp[1]))\n\ndef AccuracyQestionNum(acc_list, count):\n counter = count\n for i in range(len(acc_list)):\n if acc_list[i] == 1:\n counter += p[i]\n return counter\n\ndef MaxScoreIndex(acc_list):\n for i in reversed(range(len(acc_list))):\n if acc_list[i] == 0:\n return i\n \ndef FinalQestionNum(acc_list, score):\n remain_point = G - score\n counter = 0\n max_score_index = MaxScoreIndex(acc_list)\n for i in range(p[max_score_index]):\n remain_point -= (max_score_index+1) * 100\n counter += 1\n if remain_point <= 0:\n break\n\n if counter == p[max_score_index]:\n return None\n else:\n return counter\n \ndef ScoreCalculation(acc_list):\n score = 0\n for i in range(len(acc_list)):\n if acc_list[i] == 1:\n score += (i+1) * 100 * p[i]\n score += c[i]\n return score\n\ndef DFSQestion(acc_list):\n \n if len(acc_list) == D:\n score = ScoreCalculation(acc_list)\n if score >= G:\n question_num = AccuracyQestionNum(acc_list, 0)\n else:\n count = FinalQestionNum(acc_list, score)\n if count == None:\n return None\n else:\n question_num = AccuracyQestionNum(acc_list, count)\n return question_num\n else:\n question_num1 = DFSQestion(acc_list + [0])\n question_num2 = DFSQestion(acc_list + [1])\n if question_num1 == None:\n return question_num2\n if question_num2 == None:\n return question_num1\n if question_num1 >= question_num2:\n return question_num2\n else:\n return question_num1\n \nquestion_num = DFSQestion([])\n\nprint(question_num)\n\n\n\n']
['Wrong Answer', 'Accepted']
['s814408112', 's313234191']
[3188.0, 3188.0]
[35.0, 34.0]
[3199, 3168]
p03290
u859897687
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d,g=map(int,input().split())\ng//=100\nl=[]\nans=1000\nfor i in range(d):\n p,c=map(int,input().split())\n l+=[[p,c,i*p,i*p+c]]\n#dp[c][i]\ndp=[[0for i in range(d)]for i in range(2**d-1)]\nfor i in range(2**d-1):\n a=0\n b,c=i,0\n d=0\n while b:\n if b%2>0:\n dp[i]+=l[c][3]\n d+=l[i][0]\n else:\n a=c\n b//=2\n c+=1\n if dp[i]+l[a][2]>=g:\n ans=min(ans,d+(g-dp[i])//a+((g-dp[i])%a))\nprint(ans)\n \n', 'd,g=map(int,input().split())\ng//=100\nl=[]\nans=1000\nfor i in range(1,d+1):\n p,c=map(int,input().split())\n c//=100\n l+=[[p,c,i*p,i*p+c]]\nfor i in range(2**d):\n score=0\n a=0\n b=1\n c=0\n if not i:\n b=d\n while i:\n if i%2>0:\n score+=l[a][3]\n c+=l[a][0]\n else:\n b=a+1\n a+=1\n i//=2\n if score>=g:\n ans=min(ans,c)\n elif score+l[b-1][2]>=g:\n ans=min(ans,c+(g-score)//b+((g-score)%b>0))\nprint(ans)\n \n']
['Runtime Error', 'Accepted']
['s136014700', 's602551692']
[3188.0, 3064.0]
[19.0, 22.0]
[417, 439]
p03290
u859987056
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['rom math import ceil\n\nD, G = map(int,input().split())\npc = [list(map(int,input().split())) for i in range(D)]\n\nans = float("inf")\nfor bit in range(1 << D):\n cnt = 0\n sum = 0\n remain = set(range(1,D+1))\n\n for i in range(D):\n if bit & (1 << i):\n cnt += pc[i][0]\n sum += pc[i][0]*(i+1)*100 + pc[i][1]\n remain.discard(i+1)\n\n if sum < G:\n use = max(remain)\n n = min(pc[use-1][0], ceil((G-sum)/(use*100)))\n """\n if use == 0:\n n = 0\n elif (G - sum)%(use%100) == 0:\n n = min(pc[use-1][0], (G - sum)//(use*100))\n else:\n n = min(pc[use-1][0], (G - sum)//(use*100)+1)\n """\n cnt += n\n sum += n*use*100\n\n if sum >= G:\n ans = min(ans,cnt)\n\nprint(ans)', 'from math import ceil\n\nd,g = map(int,input().split())\npc = [list(map(int,input().split())) for i in range(d)]\n\nans = float("inf")\nfor bit in range(1<<d):\n sum = 0\n cnt = 0\n \n nokori = set(range(1, d + 1))\n for i in range(d):\n if bit & (1 << i):\n sum += pc[i][0]*100*(i+1) + pc[i][1]\n cnt += pc[i][0]\n nokori.discard(i+1)\n \n if sum < g:\n use = max(nokori)\n husoku = min(ceil((g-sum)/(use*100)),pc[use-1][0])\n cnt += husoku\n sum += husoku*use*100\n \n if sum >= g:\n ans = min(cnt,ans)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s829007565', 's844351215']
[8936.0, 9108.0]
[28.0, 36.0]
[797, 670]
p03290
u861141787
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d, g = map(int, input().split())\n\npc = []\nfor i in range(d):\n p, c = map(int, input().split())\n pc.append([(i+1)*100, p, c])\n \npc.reverse()\nans = 0\nfor i in range(d):\n #print(g, pc[i])\n s = pc[i][0] * pc[i][1] + pc[i][2]\n if g > s:\n ans += pc[i][1]\n g -= s\n else:\n if g > s - pc[i][2]:\n ans += pc[i][1]\n break\n else:\n if g % pc[i][0] == 0:\n ans += g // pc[i][0]\n else:\n ans += g // pc[i][0] + 1\n\n break\n\nprint(ans)\n\n\n', 'd, g = map(int, input().split())\n\np = [0] * 10\nc = [0] * 10\n\nfor i in range(d):\n p[i], c[i] = map(int, input().split())\n\nans = float("inf")\nfor mask in range(1<<d):\n s = 0; num = 0; rest_max = -1\n for i in range(d):\n if mask >> i & 1:\n s += 100 * (i+1) * p[i] + c[i]\n num += p[i]\n else:\n rest_max = i\n\n if s < g:\n s1 = 100 * (rest_max + 1)\n need = (g - s +s1 - 1) // s1\n if need >= p[rest_max]:\n continue\n\n num += need\n\n ans = min(ans, num)\n \nprint(ans)\n\n\n']
['Wrong Answer', 'Accepted']
['s380413206', 's916072275']
[3064.0, 3064.0]
[18.0, 24.0]
[551, 561]
p03290
u861223045
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['N = input().split()\nN = [int(i) for i in N]\npi = [0 for i in range(N[0])]\nci = [0 for i in range(N[0])]\nfor i in range(N[0]):\n buf = input().split()\n pi[i] = int(buf[0])\n ci[i] = int(buf[1])\n\nnum_min = 10*100\nG_new = N[1]\n\nflag= [0 for i in range(N[0])]\nfor i in range(0, pow(2, N[0])):\n G_new = N[1]\n count = 0\n #print(bin(i))\n for j in range(N[0]):\n flag[j] = (i>>j & 1)\n if(flag[j]==1):\n G_new -= ci[j]\n G_new -= 100*(j+1)*pi[j]\n count += pi[j]\n #print(flag)\n\n if(G_new<=0):\n #print(i, flag)\n if(count < num_min):\n #print(count)\n num_min = count\n #print(count)\n else:\n for j in range(N[0]):\n if((flag[N[0]-1-j])==0):\n #print(i, flag, N[0]-1-j, G_new, pi[N[0]-1-j], count, -(-G_new//(100*(N[0]-j))) )\n if(G_new - 100*(N[0]-j)*pi[N[0]-1-j] < 0):\n count += -(-G_new//(100*(N[0]-j)))\n if(count < num_min):\n # print(count)\n num_min = count\n \t\tbreak\n\n \nprint(num_min)\n', 'N = input().split()\nN = [int(i) for i in N]\npi = [0 for i in range(N[0])]\nci = [0 for i in range(N[0])]\nfor i in range(N[0]):\n buf = input().split()\n pi[i] = int(buf[0])\n ci[i] = int(buf[1])\n\nnum_min = 10*100\nG_new = N[1]\n\nflag= [0 for i in range(N[0])]\nfor i in range(0, pow(2, N[0])):\n G_new = N[1]\n count = 0\n #print(bin(i))\n for j in range(N[0]):\n flag[j] = (i>>j & 1)\n if(flag[j]==1):\n G_new -= ci[j]\n G_new -= 100*(j+1)*pi[j]\n count += pi[j]\n #print(flag)\n\n if(G_new<=0):\n #print(i, flag)\n if(count < num_min):\n #print(count)\n num_min = count\n #print(count)\n else:\n for j in range(N[0]):\n if((flag[N[0]-1-j])==0):\n #print(i, flag, N[0]-1-j, G_new, pi[N[0]-1-j], count, -(-G_new//(100*(N[0]-j))) )\n if(G_new - 100*(N[0]-j)*pi[N[0]-1-j] < 0):\n count += -(-G_new//(100*(N[0]-j)))\n if(count < num_min):\n # print(count)\n num_min = count\n break\n\n \nprint(num_min)\n']
['Runtime Error', 'Accepted']
['s221334395', 's403941158']
[3064.0, 3444.0]
[18.0, 26.0]
[1140, 1146]
p03290
u868982936
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['from itertools import product\nD, G = map(int, input().split())\nP, C = zip(*[map(int, input().split()) for _ in range(D)])\nINF = 10**18\nans = INF\nfor bit in product((0, 1), repeat=D):\n p = list(P)\n cnt = 0\n score = 0\n for i in range(D):\n if bit[i]:\n score += C[i]\n score += P[i]*100*(i+1)\n cnt += P[i]\n p[i] = 0\n\n\n if score+sum(p[i]*100*(i+1) for i in range(D)) < G:\n continue\n \n idx = D-1\n while score < G:\n while not p[idx]:\n idx -= 1\n score += 100*(idx+1)\n p[idx] -= 1\n cnt += 1\n if cnt < ans:\n ans = cnt\nprint(ans)', 'from itertools import product\nD, G = map(int, input().split())\nP, C = zip(*[map(int, input().split()) for _ in range(D)])\nINF = 10**18\nans = INF\nfor bit in product((0, 1), repeat=D):\n p = list(P)\n cnt = 0\n score = 0\n for i in range(D):\n if bit[i]:\n score += C[i]\n score += P[i]*100*(i+1)\n cnt += P[i]\n p[i] = 0\n \n if score+sum(p[i]*100*(i+1) for i in range(D)) < G:\n continue\n \n idx = D-1\n while score < G:\n while not p[idx]:\n idx -= 1\n score += 100*(idx+1)\n p[idx] -= 1\n cnt += 1\n if cnt < ans:\n ans = cnt\nprint(ans)']
['Runtime Error', 'Accepted']
['s126943323', 's115623096']
[3064.0, 3064.0]
[17.0, 34.0]
[649, 645]
p03290
u876438858
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import sys\nimport numpy as np\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 6)\n\n\ndef I():\n return int(input())\n\n\ndef MI():\n return map(int, input().split())\n\n\ndef LI():\n return list(MI())\n\n\ndef LIN(n: int):\n return [I() for _ in range(n)]\n\n\ninf = float("inf")\nmod = 10 ** 9 + 7\n\n\ndef main():\n d, g = MI()\n data = np.array(sys.stdin.buffer.read().split(), np.int64)\n data = data.reshape(-1, 2)\n p = data[:, 0]\n c = data[:, 1]\n\n problems = np.zeros(2 ** d, np.int64)\n points = np.zeros(2 ** d, np.int64)\n for i in range(d):\n problems[1 << i : 1 << (i + 1)] = problems[: 1 << i] + p[i]\n points[1 << i : 1 << (i + 1)] = points[: 1 << i] + c[i] + 100 * (i + 1) * p[i]\n\n for i in range(2 ** d):\n while points[i] < g:\n for j in reversed(range(d)):\n if (i >> j) & 1:\n continue\n for _ in range(p[j]):\n if points[i] >= g:\n break\n points[i] += 100 * (j + 1)\n problems[i] += 1\n\n print(problems.min())\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\nimport math\n\ninput = sys.stdin.readline\n\n\ndef I():\n return int(input())\n\n\ndef MI():\n return map(int, input().split())\n\n\ndef LI():\n return list(MI())\n\n\ninf = float("inf")\n\n\ndef main():\n d, g = MI()\n pc = [LI() for _ in range(d)]\n\n ans = inf\n for bit in range(1 << d):\n c = 0\n score = 0\n for i in range(d):\n if bit & (1 << i):\n c += pc[i][0]\n score += pc[i][0] * 100 * (i + 1) + pc[i][1]\n\n if score >= g:\n ans = min(ans, c)\n else:\n for i in reversed(range(d)):\n if bit & (1 << i):\n continue\n res = math.ceil((g - score) / (100 * (i + 1)))\n if res < pc[i][0]:\n ans = min(ans, c + res)\n break\n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s773096431', 's926850692']
[12448.0, 3064.0]
[149.0, 21.0]
[1142, 873]
p03290
u879870653
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = map(int,input().split())\nP = [0]*D\nC = [0]*D\nfor i in range(D) :\n P[i], C[i] = map(int,input().split())\n\nans = float("inf")\nfor bit in range(1 << D) :\n A = []\n score = 0\n solved = 0\n for k in range(D) :\n if bit & (1 << k) :\n A.append(k)\n score += 100*(k+1)*P[k] + C[k]\n solved += P[k]\n if score < G :\n for k in range(D-1,-1,-1) :\n if k in A :\n continue\n if G-score > 100*(k+1)*P[k] :\n score += 100*(k+1)*P[k] + C[k]\n solved += P[k]\n else :\n solved += (G-score)//(100*(k+1)*P[k]) + ((G-score)%(100*(k+1)*P[k]) != 0)\n break\n print(solved,A)\n ans = min(ans, solved)\nprint(ans)', 'from itertools import *\n\nD, G = map(int,input().split())\n\nP = [None]*D\nC = [None]*D\n\nfor i in range(D) :\n P[i], C[i] = map(int,input().split())\n\nproducts = product(range(2), repeat=D)\n\nans = float("inf")\n\nfor prod in products :\n prod = list(prod)\n \n A = []\n \n cost = 0\n score = 0\n \n for i in range(len(prod)) :\n if prod[i] == 1 :\n A.append(i)\n cost += P[i]\n score += (i+1)*100*P[i]+C[i]\n \n if score < G :\n for i in range(len(prod)-1,-1,-1) :\n if prod[i] == 1 :\n continue\n \n if score + (i+1)*100*P[i] >= G :\n if G-score < 0 :\n continue\n cost += (G-score)//((i+1)*100) + ((G-score) % ((i+1)*100) != 0)\n break\n \n else :\n cost += P[i]\n score += (i+1)*100*P[i]+C[i]\n \n ans = min(ans, cost)\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s522212834', 's656722912']
[3188.0, 3064.0]
[30.0, 27.0]
[758, 947]
p03290
u880128069
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['\n\nd, g = map(int, input().split())\n\nfor i in range(d):\n pc.append(list(map(int,input().split())))\n\nans = float("inf")\n\n\n\nfor i in range(2**d):\n count = 0 \n sum = 0\n nokori = set(range(1, d + 1)) \n\n for j in range(d):\n if (i>>j)&1:\n sum += pc[j][0] * (j + 1) * 100 + pc[j][1] \n count += pc[j][0]\n nokori.discard(j + 1) \n\n \n if sum < g:\n use = max(nokori)\n \n n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))\n count += n\n sum += n * use * 100\n\n if sum >= g:\n \n ans = min(ans, count)\n\nprint(ans)', '\n \nd, g = map(int, input().split())\npc = []\n \nfor i in range(d):\n pc.append(list(map(int,input().split())))\n \nans = float("inf")\n \n\n \nfor i in range(2**d):\n count = 0 \n sum = 0\n nokori = set(range(1, d + 1)) \n \n for j in range(d):\n if (i>>j)&1:\n sum += pc[j][0] * (j + 1) * 100 + pc[j][1] \n count += pc[j][0]\n nokori.discard(j + 1) \n \n \n if sum < g:\n use = max(nokori)\n \n n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))\n count += n\n sum += n * use * 100\n \n if sum >= g:\n \n ans = min(ans, count)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s607996143', 's691831178']
[3064.0, 3064.0]
[17.0, 25.0]
[1092, 1109]
p03290
u883792993
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = list(map(int,input().split()))\nL=[]\nfor i in range(D):\n L.append(list(map(int,input().split())))\nfor i in range(D):\n L[i].append(L[i][0]*(i+1)*100)\n L[i].append(L[i][2]+L[i][1])\nprint(L)\nanswer = 10**4\nfor bits in range(1<<D):\n point_sum = 0\n n = 0\n j = -1\n for i in range(D):\n if bits & 1<<i:\n point_sum += L[i][3]\n n += L[i][0]\n else:\n j = max(j, i)\n if point_sum >= G:\n answer = min(answer, n)\n elif j >=0 and (point_sum+L[j][2])-(j+1)*100 >= G:\n a = G - point_sum\n b = (j+1)*100\n answer = min(answer, n+int((a+b-1)/b))\n else:\n pass\nprint(answer)\n', 'D,G = list(map(int,input().split()))\nL=[]\nfor i in range(D):\n L.append(list(map(int,input().split())))\nfor i in range(D):\n L[i].append(L[i][0]*(i+1)*100)\n L[i].append(L[i][2]+L[i][1])\nanswer = 10**4\nfor bits in range(1<<D):\n point_sum = 0\n n = 0\n j = -1\n for i in range(D):\n if bits & 1<<i:\n point_sum += L[i][3]\n n += L[i][0]\n else:\n j = max(j, i)\n if point_sum >= G:\n answer = min(answer, n)\n elif j >=0 and (point_sum+L[j][2])-(j+1)*100 >= G:\n a = G - point_sum\n b = (j+1)*100\n answer = min(answer, n+int((a+b-1)/b))\n else:\n pass\nprint(answer)\n']
['Wrong Answer', 'Accepted']
['s772898355', 's519383579']
[3064.0, 3064.0]
[22.0, 22.0]
[668, 659]
p03290
u884323674
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['def rec(i, g, count, rem):\n global ans\n if i == 0:\n print(g, count, rem)\n \n if g < G:\n \n use = max(rem)\n c = min(pc[use-1][0], -(-(G-g) // (use*100)))\n count += c\n g += use*100 * c\n \n \n if g >= G:\n ans = min(ans, count)\n \n else:\n \n rec(i-1, g, count, rem)\n \n rem[i] = 0\n rec(i-1, g+i*100*pc[i-1][0]+pc[i-1][1], count+pc[i-1][0], rem)\n rem[i] = i\n\n\nD, G = map(int, input().split())\npc = [[int(i) for i in input().split()] for j in range(D)]\n\nrem = [i for i in range(D+1)]\nans = float("inf")\n\nrec(D, 0, 0, rem)\n\nprint(ans)', 'def rec(i, g, count, rem):\n global ans\n if i == 0:\n \n if g < G:\n \n use = max(rem)\n c = min(pc[use-1][0], -(-(G-g) // (use*100)))\n count += c\n g += use*100 * c\n \n \n if g >= G:\n ans = min(ans, count)\n \n else:\n \n rec(i-1, g, count, rem)\n \n rem[i] = 0\n rec(i-1, g+i*100*pc[i-1][0]+pc[i-1][1], count+pc[i-1][0], rem)\n rem[i] = i\n\n\nD, G = map(int, input().split())\npc = [[int(i) for i in input().split()] for j in range(D)]\n\nrem = [i for i in range(D+1)]\nans = float("inf")\n\nrec(D, 0, 0, rem)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s264324122', 's017931860']
[3188.0, 3064.0]
[23.0, 19.0]
[873, 844]
p03290
u886240168
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['# -*- coding: utf-8 -*-\n\nd, g = map(int, input().split())\n\np = [0] * d\nc = [0] * d\n\nfor i in range(d):\n p[i], c[i] = map(int, input().split())\n\nans = 100000\n\nsum = 0\nk = 0\n\nfor i in range(2 ** d):\n cnt = 0\n sum = 0\n\n\n for j in range(d):\n\n if (i >> j) & 1:\n sum += 100 * p[j] * (j + 1) + c[j]\n cnt += p[j]\n print(i, bin(i), j, cnt, sum)\n\n if sum >= g and ans > cnt:\n ans = cnt\n continue\n\n if g > sum:\n # print(ans, cnt, sum)\n ans = cnt\n for j in reversed(range(d)):\n if not (i >> j) & 1:\n k = j\n # print(sum, i, k)\n break\n\n if g - sum > (100 * (k + 1)) * p[k]:\n continue\n\n if g - sum <= (100 * (k + 1)) * p[k]:\n\n ans += (g - sum - 1) // (100 * (k + 1)) + 1\n\nprint(ans)\n\n', '# -*- coding: utf-8 -*-\n\nd, g = map(int, input().split())\n\np = [0] * d\nc = [0] * d\n\nfor i in range(d):\n p[i], c[i] = map(int, input().split())\n\nans = 100000\n\nsum = 0\nk = 0\n\nfor i in range(2 ** d):\n cnt = 0\n sum = 0\n k = - 1\n\n for j in range(d):\n\n if (i >> j) & 1:\n sum += 100 * p[j] * (j + 1) + c[j]\n cnt += p[j]\n\n else:\n k = j\n\n if sum < g:\n s1 = 100 * (k + 1)\n need = (g - sum + s1 - 1) // s1\n\n if need >= p[k]:\n continue\n\n cnt += need\n\n ans = min(ans, cnt)\n\nprint(ans)\n\n']
['Wrong Answer', 'Accepted']
['s780826862', 's226376062']
[3340.0, 3064.0]
[26.0, 22.0]
[846, 580]
p03290
u888337853
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import math\nimport copy\nimport sys\nimport fractions\nimport numpy as np\nfrom functools import reduce\n\n# ===FUNCTION===\n\ndef getInputInt():\n inputNum = int(input())\n return inputNum\n\ndef getInputListInt():\n outputoData = []\n inputData = input().split()\n outputData = [int(n) for n in inputData]\n\n return outputData\n\ndef getSomeInputInt(n):\n outputDataList = []\n for i in range(n):\n inputData = int(input())\n outputDataList.append(inputData)\n\n return outputDataList\n\ndef getSomeInputListInt(n):\n inputDataList = []\n outputDataList = []\n for i in range(n):\n inputData = input().split()\n inputDataList = [int(n) for n in inputData]\n outputDataList.append(inputDataList)\n\n return outputDataList\n\n# ===CODE===\n\nd, g = map(int, input().split())\ndata = getSomeInputListInt(d)\nbasecost = 100\n\nans = 0\n\nfor i in range(d):\n data[i].insert(0, i+1)\n data[i].append(0)\n\nflg = True\n\nwhile(flg):\n\n for i in range(len(data)):\n if basecost * data[i][0] * data[i][1] + data[i][2] <= g:\n data[i][3] = basecost * data[i][0] + data[i][2]/data[i][1]\n else:\n data[i][3] = basecost * data[i][0]\n\n data = sorted(data, key=lambda x:x[3], reverse=True)\n\n flg2 = True\n while(flg2):\n g -= data[0][0]*basecost\n data[0][1] -= 1\n ans += 1\n\n if data[0][1] == 0:\n g -= data[0][2]\n flg2 = False\n del data[0]\n\n if g <= 0 :\n flg2 = False\n flg = False\n\nprint(ans)', 'import math\nimport copy\nimport sys\nimport fractions\nimport numpy as np\nfrom functools import reduce\n\n\n# ===FUNCTION===\n\ndef getInputInt():\n inputNum = int(input())\n return inputNum\n\n\ndef getInputListInt():\n outputoData = []\n inputData = input().split()\n outputData = [int(n) for n in inputData]\n\n return outputData\n\n\ndef getSomeInputInt(n):\n outputDataList = []\n for i in range(n):\n inputData = int(input())\n outputDataList.append(inputData)\n\n return outputDataList\n\n\ndef getSomeInputListInt(n):\n inputDataList = []\n outputDataList = []\n for i in range(n):\n inputData = input().split()\n inputDataList = [int(n) for n in inputData]\n outputDataList.append(inputDataList)\n\n return outputDataList\n\n\n# ===CODE===\n\nbasecost = 100\n\n\ndef dfs(i, total, cnt, nokori):\n global ans\n if i == d:\n if total < g:\n use = max(nokori)\n n = min(data[use - 1][0], -(-(g - total) // (use * basecost)))\n cnt += n\n total += n * use * basecost + data[use - 1][1]\n if total >= g:\n ans = min(ans, cnt)\n else:\n dfs(i + 1, total, cnt, nokori)\n dfs(i + 1, total + (i + 1) * data[i][0] * basecost + data[i][1], cnt + data[i][0], nokori - {i+1})\n\n\nd, g = map(int, input().split())\ndata = getSomeInputListInt(d)\n\nans = sys.maxsize\n\ndfs(0, 0, 0, set(range(1, d + 1)))\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s040948032', 's151426558']
[13684.0, 13880.0]
[155.0, 160.0]
[1541, 1418]
p03290
u891635666
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["import math\n\nd, g = map(int, input().split())\nls = [[100 * (i + 1)] + list(map(int,\n input().split())) for i in range(d)][::-1]\nl0 = [a * p + c for a, p, c in ls]\n\nres = float('inf')\nfor index in range(2**d):\n cs = '{:0{d}b}'.format(int(cs))\n count = 0\n s = 0\n for i, c in enumerate(cs):\n if c == '1':\n count += ls[i][1]\n s += l0[i]\n if s < g:\n for i, c in enumerate(cs):\n if c == '0' and s + ls[i][0] * ls[i][1] >= g:\n n = math.ceil((g - s) / ls[i][0])\n count += n\n s += ls[i][0] * n\n break\n if s >= g:\n res = min(res, count)\nprint(res)", "import math\n\nd, g = map(int, input().split())\nls = [[100 * (i + 1)] + list(map(int,\n input().split())) for i in range(d)][::-1]\nl0 = [a * p + c for a, p, c in ls]\n\nres = float('inf')\nfor index in range(2**d):\n cs = '{:b}'.format(int(cs))\n cs = '0' * (d - len(cs)) + cs\n count = 0\n s = 0\n for i, c in enumerate(cs):\n if c == '1':\n count += ls[i][1]\n s += l0[i]\n if s < g:\n for i, c in enumerate(cs):\n if c == '0' and s + ls[i][0] * ls[i][1] >= g:\n n = math.ceil((g - s) / ls[i][0])\n count += n\n s += ls[i][0] * n\n break\n if s >= g:\n res = min(res, count)\nprint(res)", "import math\n\nd, g = map(int, input().split())\nls = [[100 * (i + 1)] + list(map(int,\n input().split())) for i in range(d)][::-1]\nl0 = [a * p + c for a, p, c in ls]\n\nres = float('inf')\nfor index in range(2**d):\n cs = format(index, 'b')\n cs = '{:0{d}d}'.format(int(cs))\n count = 0\n s = 0\n for i, c in enumerate(cs):\n if c == '1':\n count += ls[i][1]\n s += l0[i]\n if s < g:\n for i, c in enumerate(cs):\n if c == '0' and s + ls[i][0] * ls[i][1] >= g:\n n = math.ceil((g - s) / ls[i][0])\n count += n\n s += ls[i][0] * n\n break\n if s >= g:\n res = min(res, count)\nprint(res)", "import math\n\nd, g = map(int, input().split())\nls = [[100 * (i + 1)] + list(map(int,\n input().split())) for i in range(d)][::-1]\nl0 = [a * p + c for a, p, c in ls]\n\nres = float('inf')\nfor index in range(2**d):\n cs = '{:b}'.format(index)\n cs = '0' * (d - len(cs)) + cs\n count = 0\n s = 0\n for i, c in enumerate(cs):\n if c == '1':\n count += ls[i][1]\n s += l0[i]\n if s < g:\n for i, c in enumerate(cs):\n if c == '0' and s + ls[i][0] * ls[i][1] >= g:\n n = math.ceil((g - s) / ls[i][0])\n count += n\n s += ls[i][0] * n\n break\n if s >= g:\n res = min(res, count)\nprint(res)"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s093791227', 's213545061', 's638735235', 's612857025']
[3064.0, 3188.0, 3188.0, 3064.0]
[19.0, 17.0, 18.0, 23.0]
[701, 731, 729, 729]
p03290
u903948194
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import sys\n\nD, G = [int(n) for n in input().split()]\n\nscore_table = []\nfor i in range(1, D+1):\n p, c = [int(n) for n in input().split()]\n score_table.append([i*100, p, c])\n\nscore_table = sorted(score_table, key=lambda x:x[0], reverse=True)\n\nscore = 0\ncount = 0\nfor s, p, c in score_table:\n for i in range(1, p+1):\n score += s\n count += 1\n if i == p:\n score += c\n if score >= G:\n print(count)\n sys.exit(0)', 'import sys\n\nD, G = [int(n) for n in input().split()]\n\nscore_table = []\nfor i in range(1, D+1):\n p, c = [int(n) for n in input().split()]\n score_table.append([i*100, p, c])\n\nscore_table = sorted(score_table, key=lambda x:x[0], reverse=True)\n\nscore = 0\ncount = 0\nfor s, p, c in score_table:\n for i in range(1, p+1):\n score += s\n count += 1\n if i == p:\n score += c\n if score >= G:\n print(count)\n sys.exit(0)', 'D, G = [int(n) for n in input().split()]\n\nscore_table = []\nfor i in range(1, D+1):\n p, c = [int(n) for n in input().split()]\n score_table.append([i*100, p, c])\n\nmin_count = sum([l[1] for l in score_table])\n#print(min_count)\n\nfor bit in range(1<<D):\n score = 0\n count = 0\n\n for i in range(D):\n if bit & (1<<i):\n score += score_table[i][0] * score_table[i][1] + score_table[i][2]\n count += score_table[i][1]\n \n if score >= G:\n min_count = min(min_count, count)\n else:\n additional = []\n for j in range(D):\n if not bit & (1<<j):\n additional.append(score_table[j])\n \n additional_ = sorted(additional, key=lambda x:x[0], reverse=True)\n #print(additional_)\n \n \n # if i[1] > 1:\n # add_score = i\n # break\n\n #add_score = additional_[0]\n\n for k in range(additional_[0][1]-1):\n score += additional_[0][0]\n count += 1\n if score >= G:\n min_count = min(min_count, count)\n\nprint(min_count)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s372497371', 's869555715', 's512461322']
[9176.0, 9180.0, 9104.0]
[27.0, 29.0, 49.0]
[474, 474, 1134]
p03290
u904943473
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = map(int, input().split())\n\nlst = [list(map(int, input().split())) for i in range(D)]\n\nans = 0\ncnt = 0\nflag = False\nfor i in range(D):\n for j in range(lst[-i-1][0]):\n ans += (D - i) * 100\n if (j == lst[-i-1][0] - 1):\n ans += lst[-i-1][1]\n print(ans)\n cnt += 1\n if (ans >= G):\n flag = True\n break\n if flag:\n break\nprint(cnt)', 'D, G = map(int, input().split())\n\nlst = [list(map(int, input().split())) for i in range(D)]\n\nans = 0\ncnt = 0\nflag = False\nfor i in range(D):\n for j in range(lst[-i-1][0]):\n ans += (D - i) * 100\n if (j == lst[-i-1][0] - 1):\n ans += lst[-i-1][1]\n cnt += 1\n if (ans >= G):\n flag = True\n break\n if flag:\n break\nprint(cnt)', 'D, G = map(int, input().split())\n\nlst = [list(map(int, input().split())) for i in range(D)]\nans = []\nref = []\nfor i,v in enumerate(lst):\n\tref.append(v[0]*(i+1)*100 + v[1])\n \nfor i in range(2 ** D):\n\tscore = 0\n\tcnt = 0\n\tfor j in range(D): \n\t\tif ((i >> j) & 1): \n\t\t\tscore += ref[j]\n\t\t\tcnt += lst[j][0]\n\tif (score >= G):\n\t\tans.append(cnt)\n\telse:\n\t\tfor l in range(D)[::-1]:\n\t\t\tif ((i >> l) & 1):\n\t\t\t\tcontinue\n\t\t\tfor _ in range(1,lst[l][0]):\n\t\t\t\tscore += (l+1) * 100\n\t\t\t\tcnt += 1\n \n\t\t\t\tif score >= G:\n\t\t\t\t\tans.append(cnt) \n\t\t\t\t\tbreak\nprint(min(ans))\n \n ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s693883706', 's729722993', 's842638878']
[3188.0, 3064.0, 3064.0]
[18.0, 18.0, 150.0]
[364, 349, 586]
p03290
u909991537
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = (int(i) for i in input().split()) \nPC = [[int(i) for i in input().split()] for i in range(D)] \n\nmax_atmpt = G // (D * 100)\ntotal = 0\nans = 0\ncount = 0\npc_gain_sorted = []\nidx_list = []\nfor i, (p, c) in enumerate(PC):\n pc_gain_sorted.append((p * (i + 1) * 100 + c, i + 1, p))\npc_gain_sorted.reverse()\n\nfor gain, idx, _ in pc_gain_sorted:\n if total + gain <= G:\n total += gain\n idx_list.append(idx) # start from 1\n count += PC[idx - 1][0]\n \nfor gain, idx, p in pc_gain_sorted:\n if idx not in idx_list:\n break\n\nfor i in range(10):\n tmp = []\n for j, (p, c) in enumerate(PC):\n if i + 1 \n \ttmp.append((j + 1) * 100 * (i + 1)\n \n\nprint(ans + count)', 'D, G = (int(i) for i in input().split()) \nPC = [[int(i) for i in input().split()] for i in range(D)] \n\ns = 0\nQ = []\nfor i, (p, c) in enumerate(PC):\n s += p\n Q.append((i+1, p, c))\n \ndp = [-10**18]*(s+1)\ndp[0] = 0\n\nfor i, p, c in Q:\n for j in range(s, -1, -1): \n for k in range(1, p+1): \n if k == p:\n cc = 100*i*k + c\n else:\n cc = 100*i*k\n if j - k >= 0:\n dp[j] = max(dp[j], dp[j - k] + cc)\n\nfor i, total in enumerate(dp):\n if total >= G:\n print(i)\n break']
['Runtime Error', 'Accepted']
['s783375892', 's837148832']
[3064.0, 3064.0]
[17.0, 698.0]
[673, 589]
p03290
u917558625
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G=map(int,input().split())\noe=[]\nfor i in range(D):\n p,c=map(int,input().split())\n oe.append([(c+p*100*(i+1))/p,p,c,i+1])\noe.sort(reverse=True)\nans=0\nco=0\nfor i in range(D):\n for j in range(oe[i][1]):\n co+=1\n ans+=100*oe[i][3]\n if j==oe[i][1]-1:\n ans+=oe[i][2]\n if G<=ans:\n print(co)\n exit()', 'D,G=map(int,input().split())\np=[list(map(int,input().split())) for _ in range(D)]\nc=0\nd=0\nfor i in range(D):\n d+=p[i][0]\ndp=[[0]*(d+1)for i in range(D)]\nfor i in range(D):\n for j in range(p[i][0]+1):\n if i==0:\n if j==p[i][0]:\n dp[i][j]+=p[i][1]\n dp[i][j]+=100*j\n else:\n for k in range(c+1):\n if j==p[i][0]:\n dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1)+p[i][1])\n else:\n dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1))\n c+=p[i][0]\nfor i in range(d+1):\n if dp[D-1][i]>=G:\n print(i)\n break']
['Wrong Answer', 'Accepted']
['s492615790', 's434558944']
[9144.0, 9252.0]
[32.0, 278.0]
[323, 562]
p03290
u920299620
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G=map(int,input().split())\np=[0]*D\nc=[0]*D\n_max=[0]*D\nfor i in range(D):\n p[i],c[i]=map(int,input().split())\n\n\nkosupa={}\nfor i in range(D):\n kosupa[i]=100*(i+1) + c[i]/p[i]\n\nsorted_kosupa=sorted(kosupa.items(),key=lambda x:x[1])\n\nresult=[]\nsousa=[]\nwhile(1):\n tmp=sorted_kosupa.pop()\n min_num=p[tmp[0]]\n min_ind=tmp[0]\n for i in range(D):\n if(i in sousa):\n continue\n tmp_num=(G-1)//(100*(i+1))+1\n if(tmp_num <= min_num and tmp_num<=p[i]):\n min_num=tmp_num\n min_ind=i\n result.append([min_ind,min_num])\n G-=100*(min_ind+1)*min_num\n if(min_num==p[min_ind]):\n G-=c[min_ind]\n sousa.append(min_ind)\n if(G<=0):\n break\n\ntotal=0\nfor k in result:\n total+=k[1]\n\nprint(total)', 'D,G=map(int,input().split())\np=[0]*D\nc=[0]*D\n_max=[0]*D\nfor i in range(D):\n p[i],c[i]=map(int,input().split())\n\n\nkosupa={}\nfor i in range(D):\n kosupa[i]=100*(i+1) + c[i]/p[i]\n\nsorted_kosupa=sorted(kosupa.items(),key=lambda x:x[1])\n\nresult=[]\nsousa=[]\nwhile(1):\n tmp=sorted_kosupa.pop()\n min_num=p[tmp[0]]\n min_ind=tmp[0]\n for i in range(D):\n if(i in sousa):\n continue\n tmp_num=(G-1)//(100*(i+1))+1\n if(tmp_num < min_num and tmp_num<=p[i]):\n min_num=tmp_num\n min_ind=i\n result.append([min_ind,min_num])\n G-=100*(min_ind+1)*min_num\n if(min_num==p[min_ind]):\n G-=c[min_ind]\n sousa.append(min_ind)\n if(G<=0):\n break\n\ntotal=0\nfor k in result:\n total+=k[1]\n\nprint(total)', 'from math import ceil\nD,G=map(int,input().split())\np=[0]*D\nc=[0]*D\n\nfor i in range(D):\n p[i],c[i]=map(int,input().split())\n_min=101*D\n\nflag=0\nwhile(flag < 2**D):\n \n _G=G\n tmp=0\n max_ind=0\n for i in range(D):\n if(flag & 1<<i):\n _G-=p[i]*(i+1)*100 + c[i]\n tmp+=p[i]\n else:\n max_ind=i\n k=ceil( max([(_G),0]) / (100*(max_ind+1)) ) \n if(k < p[max_ind] or k==0):\n tmp+=k\n _min=min([tmp,_min])\n flag+=1\nprint(_min) ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s500416942', 's795344155', 's502044962']
[3064.0, 3064.0, 3064.0]
[17.0, 19.0, 24.0]
[769, 768, 497]
p03290
u921773161
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['#%%\nimport itertools\nimport math\n\nD, G = map(int, input().split())\np = [0] * D\nc = [0] * D\ncom = [0] * D\nfor i in range(D):\n p[i], c[i] = map(int, input().split())\n com[i] = [100 * (i+1) * p[i] + c[i], p[i]]\n\nl = list(itertools.product(range(2), repeat=D))\nscore_list = []\nfor i in range(len(l)):\n tmp1 = 0\n tmp2 = []\n tmp3 = -1\n tmp5 = 0\n for j in range(D):\n if l[i][j] == 0:\n tmp2.append(j)\n pass\n else:\n tmp1 += com[j][0]\n tmp5 += com[j][1]\n if len(tmp2) != 0:\n tmp3 = tmp2[-1]\n if tmp3 != -1:\n tmp4 = tmp1 + (tmp3+1) * 100 * (p[tmp3]-1)\n else:\n tmp4 = tmp1\n \n score_list.append([tmp1, tmp3, tmp4, tmp5])\n\n#print(score_list)\n\nans_list = []\n\nfor i in range(len(score_list)):\n if score_list[i][1] != -1:\n if score_list[i][0]<= G and score_list[i][2] >= G:\n tmp = math.ceil((G - score_list[i][0]) / ((score_list[i][1]+1)*100))\n ans = score_list[i][3] + tmp\n ans_list.append(ans)\n print(score_list[i][3], ans)\n else:\n if score_list[i][0]>= G:\n ans_list.append(score_list[i][3])\n\n#print(ans_list)\nprint(min(ans_list))\n\n', 'import itertools\nD, G = map(int, input().split())\np = [0] * D\nc = [0] * D\npc = [0] * D\nfor i in range(D):\n p[i], c[i] = map(int, input().split())\n\nl = list(itertools.product(range(2), repeat=D))\n\ncomp = []\nfor i in range(len(l)-1):\n score = 0\n count = 0\n m = -100\n for j in range(D):\n if l[i][j] == 1:\n score += (j+1) * 100 * p[j] + c[j]\n count += p[j]\n elif l[i][j] == 0:\n m = max(m, j)\n tmp = [score, count]\n comp.append(tmp)\n for j in range(p[m]-1):\n score += (m+1) * 100 * 1\n count += 1\n tmp = [score, count]\n comp.append(tmp)\n\nscore = 0\ncount = 0\nfor i in range(D):\n score += (i+1) * 100 * p[i] + c[i]\n count += p[i]\ntmp = [score, count]\ncomp.append(tmp) \n\n#print(comp)\n\nans = []\nfor i in range(len(comp)):\n if comp[i][0] >= G:\n ans.append(comp[i][1])\n\nans = min(ans)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s310080987', 's513133338']
[3444.0, 20888.0]
[23.0, 118.0]
[1207, 902]
p03290
u922449550
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['\nD, G = map(int, input().split())\nG //= 100\npc = []\nfor d in range(D):\n p, c = map(int, input().split())\n pc.append([p, c//100])\n\n\nans = 10 ** 4\n\nfor i in range(2**D):\n points = 0\n num = 0\n idx = -1\n for d in range(D):\n \n if i>>d & 1:\n points += pc[d][0]*(d+1) + pc[d][1]\n num += pc[d][0]\n else:\n idx = d\n if points >= G:\n ans = min(ans, num)\n elif idx >= 0: \n num_add = - (- (G - points) // (idx + 1))\n print((-(G-points)) // (idx+1))\n if num_add <= pc[idx][0]:\n ans = min(ans, num + num_add)\n\nprint(ans)', '\nD, G = map(int, input().split())\nG //= 100\npc = []\nfor d in range(D):\n p, c = map(int, input().split())\n pc.append([p, c//100])\n\n\nans = 10 ** 4\n\nfor i in range(2**D):\n points = 0\n num = 0\n idx = -1\n for d in range(D):\n \n if i>>d & 1:\n points += pc[d][0]*(d+1) + pc[d][1]\n num += pc[d][0]\n else:\n idx = d\n if points >= G:\n ans = min(ans, num)\n elif idx >= 0: \n num_add = - (- (G - points) // (idx + 1))\n if num_add <= pc[idx][0]:\n ans = min(ans, num + num_add)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s038143048', 's027435826']
[3188.0, 3064.0]
[23.0, 22.0]
[845, 809]
p03290
u932864155
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = map(int,input().split())\np = [0]*int(D)\nc = [0]*int(D)\nfor i in range(D):\n p[i],c[i] = map(int,input().split())\ntotal = 0\nfor i in range(D):\n total += p[i] * (i+1) * 100 + c[i]\nans = sum(p)\nj = 0\npi = p[j]\nwhile total>=G:\n if pi==0 and j<(D-1):\n j += 1\n pi = p[j]\n if pi==p[j]:\n total -= c[j]\n total -= (j+1)*100\n pi -= 1\n ans -= 1\nprint(ans+1)', 'D,G = map(int,input().split())\np = [0]*int(D)\nc = [0]*int(D)\nfor i in range(D):\n p[i],c[i] = map(int,input().split())\nans = 1e9\nfor i in range(2**D):\n s = 0\n num = 0\n rest_max = -1\n for j in range(D):\n if (i>>j)&1:\n s += 100 * (j+1) * p[j] + c[j]\n num += p[j]\n else:\n rest_max = j\n if s<G:\n s1 = 100 * (rest_max + 1)\n need = int((G - s + s1 - 1) / s1)\n if need >= p[rest_max]:\n continue\n num += need\n ans = min(ans, num)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s202600291', 's098642995']
[3188.0, 3064.0]
[19.0, 22.0]
[366, 476]
p03290
u933622697
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import sys\n\nsys_input = sys.stdin.readline\n\nD, G = map(int, sys_input().split())\npc_list = [tuple(map(int, sys_input().split())) for _ in range(D)]\n\n# WIP\ntemp_min_score = 10000000000000000\ncombi_min = []\nn_solved = 10000000000\nfor i in range(1 << D):\n score_per_combi = 0\n combi = []\n tmp_n_solved = 0\n \n for j in range(D):\n if (i >> j) & 1:\n p = pc_list[j][0]\n c = pc_list[j][1]\n score_per_combi += (j + 1) * 100 * p + c\n combi.append(j)\n tmp_n_solved += p\n if tmp_n_solved == 0:\n continue\n if score_per_combi >= G and tmp_n_solved < n_solved:\n temp_min_score = score_per_combi\n combi_min = combi\n n_solved = tmp_n_solved\n\n# problems are already sorted\n# -> check the problems were oversolved\ntmp_reduced = temp_min_score\nfor problem_idx in combi_min:\n for solved_num in range(pc_list[problem_idx][0]):\n if solved_num == 1:\n c = pc_list[problem_idx][1]\n diff = (problem_idx + 1) * 100 + c\n tmp_reduced -= diff\n else:\n diff = (problem_idx + 1) * 100\n tmp_reduced -= diff\n n_solved -= 1\n \n if tmp_reduced < G:\n print(n_solved + 1)\n exit()\n\nprint(n_solved)\n', 'import sys\n\nsys_input = sys.stdin.readline\n\nD, G = map(int, sys_input().split())\npc_list = [tuple(map(int, sys_input().split())) for _ in range(D)]\n\nn_solved = 10000000000\nfor i in range(1 << D):\n score_per_combi = 0\n combi = []\n tmp_n_solved = 0\n\n for j in range(D):\n if (i >> j) & 1:\n p = pc_list[j][0]\n c = pc_list[j][1]\n score_per_combi += (j + 1) * 100 * p + c\n combi.append(j)\n tmp_n_solved += p\n\n if tmp_n_solved == 0:\n continue\n if score_per_combi < G:\n continue\n\n # problems are already sorted\n # -> check if these were oversolved\n for problem_idx in combi:\n for solved_num in range(pc_list[problem_idx][0]):\n diff = None\n if solved_num == 1:\n c = pc_list[problem_idx][1]\n diff = (problem_idx + 1) * 100 + c\n score_per_combi -= diff\n else:\n diff = (problem_idx + 1) * 100\n score_per_combi -= diff\n tmp_n_solved -= 1\n\n if score_per_combi < G:\n tmp_n_solved += 1\n score_per_combi += diff\n break\n \n else:\n continue\n \n break\n\n # Check if mininum n_solved are updated\n if tmp_n_solved < n_solved:\n n_solved = tmp_n_solved\n\nprint(n_solved)\n', '# AC\nimport math\n\nD, G = map(int, input().split())\np_c_list = [list(map(int, input().split())) for _ in range(D)]\n\nmin_n_solved = 1000000000\nfor p_combi in range(1 << D):\n tmp_score = 0\n n_solved = 0\n selected_p_idxs = [] # Selected indexes of problems\n for digit in range(D):\n if (p_combi >> digit) & 1:\n \n \n tmp_score += \\\n 100 * (digit+1) * p_c_list[digit][0] + p_c_list[digit][1]\n n_solved += p_c_list[digit][0]\n selected_p_idxs.append(digit)\n score_diff = tmp_score - G\n # print(\'1:\', n_solved, \'score_diff:\', score_diff)\n if score_diff >= 0:\n # Fine-tuning to reduce "n_solved" problems over solved\n # "selected_p_idxs" were already sorted by probrems\n # from low points to high\n p_idx_lowest = selected_p_idxs[0]\n score_per_p = 100 * (p_idx_lowest + 1)\n # if score_diff - bonus_point > 0\n n_oversolved = None\n score_diff_wo_bonus = score_diff - p_c_list[p_idx_lowest][1]\n if score_diff_wo_bonus > 0:\n n_oversolved = round(score_diff_wo_bonus / score_per_p)\n if n_oversolved < p_c_list[p_idx_lowest][0]:\n n_solved -= n_oversolved\n # print(\'2:\', n_solved)\n else:\n not_selected_p_idxs = \\\n [p_idx for p_idx in range(D) if p_idx not in selected_p_idxs]\n not_selected_p_idxs = sorted(not_selected_p_idxs, reverse=True)\n # Select a problem index\n # which have highest point in not_selected_p_idxes\n not_selected_p_idx_highest = not_selected_p_idxs[0]\n num_p = p_c_list[not_selected_p_idx_highest][0]\n addable_score = \\\n 100 * num_p * (not_selected_p_idx_highest + 1)\n if score_diff + addable_score > 0:\n score_per_p = 100 * (not_selected_p_idx_highest + 1)\n n_undersolved = math.ceil(abs(score_diff) / score_per_p)\n if n_undersolved < num_p:\n n_solved += n_undersolved\n # print(\'3:\', n_solved)\n if n_solved > 0 and score_diff >= 0:\n min_n_solved = min(n_solved, min_n_solved)\n\nprint(min_n_solved)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s343640877', 's932648575', 's935254210']
[3064.0, 3064.0, 3064.0]
[22.0, 174.0, 26.0]
[1282, 1487, 2203]
p03290
u934868410
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['d, g = map(int, input().split())\np = []\nc = []\nsu = []\nans = 1000\nfor i in range(d):\n a,b = map(int, input().split())\n p.append(a)\n c.append(b)\n su.append(a*100*(i+1)+b)\nbit = [1,2,4,8,16,32,64,128,256,512]\nfor i in range(1024):\n count = 0\n for j in range(d):\n if i & bit[j] == 0:\n continue\n score += su[j]\n count += p[j]\n if score < g:\n continue\n for j in range(d):\n if i & bit[j] == 0 or score - su[j] >= g:\n continue\n rest = g - (score - su[j])\n count_tmp = count - p[j] + math.ceil(rest / ((d+i)*100))\n ans = min(ans, count_tmp)\nprint(ans)', 'import math\nd, g = map(int, input().split())\np = []\nc = []\nsu = []\nans = 1000\nfor i in range(d):\n a,b = map(int, input().split())\n p.append(a)\n c.append(b)\n su.append(a*100*(i+1)+b)\nbit = [1,2,4,8,16,32,64,128,256,512]\nfor i in range(1024):\n count = 0\n for j in range(d):\n if i & bit[j] == 0:\n continue\n score += su[j]\n count += p[j]\n if score < g:\n continue\n for j in range(d):\n if i & bit[j] == 0 or score - su[j] >= g:\n continue\n rest = g - (score - su[j])\n count_tmp = count - p[j] + math.ceil(rest / ((d+i)*100))\n ans = min(ans, count_tmp)\nprint(ans)', 'import math\nd, g = map(int, input().split())\np = []\nc = []\nsu = []\nans = 1000\nfor i in range(d):\n a,b = map(int, input().split())\n p.append(a)\n c.append(b)\n su.append(a*100*(i+1)+b)\nbit = [1,2,4,8,16,32,64,128,256,512]\nfor i in range(int(math.pow(2,d))):\n count = 0\n score = 0\n for j in range(d):\n if i & bit[j] == 0:\n continue\n score += su[j]\n count += p[j]\n if score < g:\n continue\n for j in range(d):\n if i & bit[j] == 0 or score - su[j] >= g:\n continue\n rest = g - (score - su[j])\n count_tmp = min(count , count - p[j] + math.ceil(rest / ((j+1)*100)))\n ans = min(ans, count_tmp)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s177296811', 's679996340', 's098866702']
[3064.0, 3064.0, 3064.0]
[17.0, 18.0, 24.0]
[585, 597, 636]
p03290
u940652437
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G=map(int,input().split())\npc=[list(map(int,input().split())) for i in range(D)]\nprint(pc)\nans=G // 100\n\nfor i in range(2**D):\n score=0\n b=0\n cnt=0\n for j in range(D):\n if ((i>>j)&1):\n score+=100*(j+1)*pc[j][0]+pc[j][1]\n cnt+=pc[j][0]\n else:\n b=j\n for k in range(pc[b][0]):\n print(ans)\n if score>=G and cnt<ans:\n ans=cnt\n score+=(b+1)*100\n cnt+=1\nprint(ans)', 'D,G=map(int,input().split())\npc=[list(map(int,input().split())) for i in range(D)]\nprint(pc)\nans=G // 100\n\nfor i in range(2**D):\n score=0\n b=0\n cnt=0\n for j in range(D):\n if ((i>>j)&1):\n score+=100*(j+1)*pc[j][0]+pc[j][1]\n cnt+=pc[j][0]\n else:\n b=j\n for k in range(pc[b][0]):\n if score>=G and cnt<ans:\n ans=cnt\n score+=(b+1)*100\n cnt+=1\nprint(ans)\n', 'D,G=map(int,input().split())\npc=[list(map(int,input().split())) for i in range(D)]\nans=G // 100\n\nfor i in range(2**D):\n score=0\n b=0\n cnt=0\n for j in range(D):\n if ((i>>j)&1):\n score+=100*(j+1)*pc[j][0]+pc[j][1]\n cnt+=pc[j][0]\n else:\n b=j\n for k in range(pc[b][0]):\n if score>=G and cnt<ans:\n ans=cnt\n score+=(b+1)*100\n cnt+=1\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s236787695', 's272357562', 's016234210']
[9252.0, 9180.0, 9212.0]
[83.0, 59.0, 55.0]
[460, 442, 431]
p03290
u945181840
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import itertools\nD, G = map(int, input().split())\nscore_list = []\nfor i in range(D):\n p, c = map(int, input().split())\n score_list.append([(i + 1) * 100] * (p - 1) + [c + (i + 1) * 100])\nfull_score = [sum(i) for i in score_list]\nper = list(itertools.permutations(range(D)))\nans = 10000\nprint(score_list)\n\nfor k in per:\n pro = 0\n sco = 0\n for i in k:\n if G >= sco + full_score[i]:\n sco += full_score[i]\n pro += len(score_list[i])\n else:\n for j in score_list[i]:\n sco += j\n pro += 1\n if sco >= G:\n break\n else:\n continue\n if sco >= G:\n break\n else:\n continue\n if ans > pro:\n ans = pro\n else:\n continue\nprint(ans)', "D, G = map(int, input().split())\nscore_list = []\nfor i in range(D):\n p, c = map(int, input().split())\n score_list.append([(i + 1) * 100] * (p - 1) + [c + (i + 1) * 100])\nfull_score = [sum(i) for i in score_list]\nsol = [format(i, 'b').zfill(D) for i in range(2 ** D)]\nans = []\n\nfor i in sol:\n problem = 0\n score = 0\n for j in range(D):\n if i[j] == '1':\n score += full_score[j]\n problem += len(score_list[j])\n else:\n continue\n if score >= G:\n ans.append(problem)\n else:\n if score + full_score[i.rfind('0')] < G:\n continue\n else:\n while score < G:\n score += score_list[i.rfind('0')][0]\n problem += 1\n ans.append(problem)\n\nprint(min(ans))"]
['Wrong Answer', 'Accepted']
['s671366005', 's601104160']
[500292.0, 3064.0]
[2136.0, 48.0]
[826, 786]
p03290
u955125992
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['def dfs(i, total, S, remain):\n global ans\n if i == D:\n if S < G:\n """\n If all the problems of the segment don\'t have to be calculated,\n it is preferable to solve some of the segment with the highest rate.\n """\n use = max(remain)\n N = min(L[use-1][0], (G-S)//(100*L[use-1][0]))\n S += 100 * N * use\n total += N\n \n if S >= G:\n ans = min(ans, total)\n else:\n dfs(i+1, total, S, remain)\n dfs(i+1, total + L[i+1][0], S + 100 * (i+1) * L[i+1][0] + L[i+1][1], remain - (i+1))\n\nD, G = map(int, input().split())\nL = [list(map(int, input().split())) for _ in range(D)]\nans = 10 ** 9\n\ndfs(0, 0, 0, set(range(1, D+1)))\n\nprint(ans)', 'def dfs(i, total, S, remain):\n global ans\n if i == D:\n if S < G:\n """\n If all the problems of the segment don\'t have to be calculated,\n it is preferable to solve some of the segment with the highest rate.\n """\n use = max(remain)\n N = min(L[use-1][0], (G-S)//(100*L[use-1][0])\n S += 100 * N * use\n total += N\n \n if S >= G:\n ans = min(ans, total)\n else:\n dfs(i+1, total, S, remain)\n dfs(i+1, total + L[i+1][0], S + 100 * (i+1) * L[i+1][0] + L[i+1][1], remain - (i+1))\n\nD, G = map(int, input().split())\nL = [list(map(int, input().split())) for _ in range(D)]\nans = 10 ** 9\n\ndfs(0, 0, 0, set(range(1, D+1)))\n\nprint(ans)', 'def dfs(i, total, S, remain):\n global ans\n if i == D:\n if S < G:\n use = max(remain)\n N = min(L[use-1][0], (G-S)//(100*use)\n S += 100 * N * use\n total += N\n \n if S >= G:\n ans = min(ans, total)\n else:\n dfs(i+1, total, S, remain)\n dfs(i+1, total + L[i][0], S + 100 * (i+1) * L[i][0] + L[i][1], remain - {i+1})\n\nD, G = map(int, input().split())\nL = [list(map(int, input().split())) for _ in range(D)]\nans = 10 ** 9\n\ndfs(0, 0, 0, set(range(1, D+1)))\n\nprint(ans)', '\ndef dfs(i, total, S, remain):\n global ans\n if i == D:\n if S < G:\n use = max(remain)\n N = min(L[use-1][0], -(-(G-S)//(100*use)))\n S += 100 * N * use\n total += N\n \n if S >= G:\n ans = min(ans, total)\n else:\n dfs(i+1, total, S, remain)\n dfs(i+1, total + L[i][0], S + 100 * (i+1) * L[i][0] + L[i][1], remain - {i+1})\n\nD, G = map(int, input().split())\nL = [list(map(int, input().split())) for _ in range(D)]\nans = 10 ** 9\n\ndfs(0, 0, 0, set(range(1, D+1)))\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s742281804', 's856037772', 's943182197', 's242679318']
[3064.0, 3064.0, 3064.0, 3064.0]
[18.0, 17.0, 17.0, 19.0]
[753, 749, 553, 559]
p03290
u961288441
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = map(int, input().split())\nPC = [0]+[list(map(int,input().split())) for _ in range(D)]\n\ndef dfs(d, g):\n if(d == 0):\n return 1e9\n\n c = min(g//(100*d), PC[d][0])\n s = 100*d*c\n if c == PC[d][0]:\n s += PC[d][1]\n if s<g:\n c += f(d-1, g-s)\n return min(c, f(d-1,g))\n\nprint(dfs(D, G))', 'D, G = map(int, input().split())\nPC = [0]+[list(map(int,input().split())) for _ in range(D)]\nprint(1e9)\n\ndef dfs(d, g):\n if(d == 0):\n return 1e9\n\n c = min(g//(100*d), PC[d][0])\n s = 100*d*c\n if c == PC[d][0]:\n s += PC[d][1]\n if s<g:\n c += f(d-1, g-s)\n return min(c, f(d-1,g))\n\nprint(dfs(D, G))', 'D, G = map(int, input().split())\nPC = [0]+[list(map(int,input().split())) for _ in range(D)]\n\ndef dfs(d, g):\n # if(d == 0):\n # return 1e9\n\n c = min(g//(100*d), PC[d][0])\n s = 100*d*c\n if c == PC[d][0]:\n s += PC[d][1]\n if s<g:\n c += f(d-1, g-s)\n return min(c, f(d-1,g))\n\nprint(dfs(D, G))', 'D, G = map(int, input().split())\nPC = [0]+[list(map(int,input().split())) for _ in range(D)]\nprint(1e9)\n\ndef dfs(d, g):\n # if(d == 0):\n # return 1e9\n\n c = min(g//(100*d), PC[d][0])\n s = 100*d*c\n if c == PC[d][0]:\n s += PC[d][1]\n if s<g:\n c += f(d-1, g-s)\n return min(c, f(d-1,g))\n\nprint(dfs(D, G))', 'D, G = map(int, input().split())\nPC = [0]+[list(map(int,input().split())) for _ in range(D)]\n\ndef dfs(d, g):\n if(d == 0):\n return 1e9\n\n c = min(g//(100*d), PC[d][0])\n s = 100*d*c\n if c == PC[d][0]:\n s += PC[d][1]\n if s<g:\n c += dfs(d-1, g-s)\n return min(c, dfs(d-1,g))\n\nprint(dfs(D, G))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s598775738', 's752638232', 's824072777', 's826319821', 's766243932']
[9212.0, 9132.0, 9192.0, 9120.0, 9216.0]
[22.0, 23.0, 28.0, 27.0, 32.0]
[321, 332, 325, 336, 325]
p03290
u961595602
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = map(int, input().split())\n\nScore = []\nq_sum = 0\nfor i in range(D):\n p, c = map(int, input().split())\n q_sum += p\n Score.append([(i+1)*100, p, c])\n\ndef Calc(score, num):\n temp = list(filter(lambda x: x[1] < num+1, score))\n if temp == []:\n return score[-1][0] * num\n else:\n cand = []\n if len(score) == 1:\n cand.append(temp[0][0]*temp[0][1] + temp[0][2])\n else:\n copy_score = score.copy()\n for t in temp:\n temp_score = score.copy()\n del temp_score[temp_score.index(t)]\n del copy_score[copy_score.index(t)]\n cand.append(t[0]*t[1] + t[2] + Calc(temp_score, num - t[1]))\n if len(copy_score) > 0:\n cand.append(copy_score[-1][0] * num)\n return max(cand)\n\na, b = 1, q_sum+1\nwhile (b-a) > 1:\n print(a, b)\n if Calc(Score, (b+a) // 2) >= G:\n b = (b+a) // 2\n else:\n a = (b+a) // 2\nif Calc(Score, a) >= G:\n print(a)\nelse:\n print(b)\n', 'D, G = map(int, input().split())\n\nScore = []\nq_sum = 0\nfor i in range(D):\n p, c = map(int, input().split())\n q_sum += p\n Score.append([(i+1)*100, p, c])\n\ndef Calc(score, num):\n temp = list(filter(lambda x: x[1] < num+1, score))\n if temp == []:\n return score[-1][0] * num\n else:\n cand = []\n if len(score) == 1:\n cand.append(temp[0][0]*temp[0][1] + temp[0][2])\n else:\n copy_score = score.copy()\n for t in temp:\n temp_score = score.copy()\n del temp_score[temp_score.index(t)]\n del copy_score[copy_score.index(t)]\n cand.append(t[0]*t[1] + t[2] + Calc(temp_score, num - t[1]))\n if len(copy_score) > 0:\n cand.append(copy_score[-1][0] * num)\n return max(cand)\n\na, b = 1, q_sum+1\nwhile (b-a) > 2:\n print(a,b)\n if Calc(Score, (b+a) // 2) >= G:\n b = (b+a) // 2\n else:\n a = (b+a) // 2\nif Calc(Score, a) >= G:\n print(a)\nelse:\n print(b)\n', '# -*- coding: utf-8 -*-\nfrom sys import stdin\nimport math\n\ns_in = lambda: stdin.readline()[:-1] \nd_in = lambda: int(stdin.readline()) # N = d_in()\nds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()\n\nD, G = ds_in()\n\nScore = []\nfor i in range(D):\n p, c = ds_in()\n Score.append([(i+1)*100, p, c])\n\nINF = 10**10\n\nsearch = []\ndef SearchMin(search, idx):\n if idx == D:\n score = 0\n num = 0\n res = []\n maxprob = [0, 0, 0]\n for s, i in zip(Score, search):\n num += s[1] * i\n score += (s[0] * s[1] + s[2]) * i\n if i == 0 and s[0] > maxprob[0]:\n maxprob = s.copy()\n if (G > score) and (math.ceil((G - score) / maxprob[0]) <= maxprob[1]):\n return num + max(0, math.ceil((G - score) / maxprob[0]))\n elif G <= score:\n return num\n else:\n return INF\n\n else:\n s0 = search.copy()\n s0.append(0)\n s1 = search.copy()\n s1.append(1)\n idx += 1\n ans0 = SearchMin(s0, idx)\n ans1 = SearchMin(s1, idx)\n return min(ans0, ans1)\n\nprint(SearchMin(search, 0))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s082957063', 's170661351', 's045284523']
[3316.0, 3188.0, 3064.0]
[2104.0, 2104.0, 24.0]
[1026, 1025, 1166]
p03290
u970899068
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["x = [list(map(int, input().split())) for i in range(d)]\nans2=float('inf')\n\nfor i in range(2**d):\n v=[0]*d\n ans=0\n ans1=0\n for j in range(d):\n if (i>>j)&1==1:\n ans+=(x[j][0]*100*(j+1))+x[j][1]\n ans1+=x[j][0]\n v[j]=1\n\n\n if ans<g:\n for k in range(d):\n if v[d-k-1]==0:\n if g-ans<=(x[d-k-1][0]-1)*100*(d-k):\n w=-(-(g-ans)//(100*(d-k)))\n\n ans2=min(ans2,ans1+w)\n else:\n break\n else:\n ans2=min(ans2,ans1)\nprint(ans2)", "d,g= map(int, input().split())\nx = [list(map(int, input().split())) for i in range(d)]\nans2=float('inf')\n\nfor i in range(2**d):\n v=[0]*d\n ans=0\n ans1=0\n for j in range(d):\n if (i>>j)&1==1:\n ans+=(x[j][0]*100*(j+1))+x[j][1]\n ans1+=x[j][0]\n v[j]=1\n\n\n if ans<g:\n for k in range(d):\n if v[d-k-1]==0:\n if g-ans<=(x[d-k-1][0]-1)*100*(d-k):\n w=-(-(g-ans)//(100*(d-k)))\n\n ans2=min(ans2,ans1+w)\n else:\n break\n else:\n ans2=min(ans2,ans1)\nprint(ans2)"]
['Runtime Error', 'Accepted']
['s160223058', 's197153549']
[3064.0, 3064.0]
[18.0, 25.0]
[578, 609]
p03290
u971124021
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["from collections import deque\nimport itertools, math\nd,g = list(map(int,input().split()))\npc = [list(map(int,input().split())) for _ in range(d)]\ng /= 100\n\npat = deque([[] for _ in range(3)])\nfor i in sorted(range(d),reverse=True):\n if pc[i][0]*(i+1) >= g:\n pat[0].append(i)\n elif pc[i][0]*(i+1) + pc[i][1]//100 >= g:\n pat[1].append(i)\n else:\n pat[2].append(i)\n\npat = deque(pat[0] + pat[1] + pat[2])\n\n#ans = sum([pc[x][0] for x in range(d)])\nans = float('inf')\n\ndef dfs(i, point, cnt, pat):\n global ans\n if point < g:\n n = min(pc[i][0], math.ceil((g-point)/(i+1)) )\n point += n*(i+1)\n cnt += n\n if n == pc[i][0]:\n point += pc[i][1]//100\n print(i,point,cnt) \n if point >= g:\n ans = min(ans, cnt)\n point = 0\n cnt = 0\n \n if len(pat) > 1:\n pat.popleft()\n dfs(pat[0], point, cnt, pat)\n\ndfs(pat[0],0,0,pat)\nprint(ans)", "from collections import deque\nimport itertools, math\nd,g = list(map(int,input().split()))\npc = [list(map(int,input().split())) for _ in range(d)]\ng /= 100\n\n#ans = sum([pc[x][0] for x in range(d)])\nans = float('inf')\nfor bit in range(1<<d):\n cnt = 0\n point = 0\n pat = set(range(1,d+1))\n \n for i in range(d):\n if bit & (1<<i):\n point += pc[i][0]*(i+1) + pc[i][1]//100\n cnt += pc[i][0]\n pat.discard(i+1)\n \n if point < g:\n next = max(pat)\n n = min(pc[next-1][0], math.ceil((g - point)/(next)))\n cnt += n\n point += n*(next)\n \n if point >= g:\n print(ans,cnt)\n ans = min(ans,cnt)\n\n\nprint(ans)\n \n ", "d,g = list(map(int,input().split()))\npc = [list(map(int,input().split())) for _ in range(d)]\n\nans = float('inf')\n\nfor bit in range(1<<d):\n sum = 0\n cnt = 0\n rem = set(range(d))\n for i in range(d):\n if bit & 1<<i:\n sum += pc[i][0]*(i+1)*100 + pc[i][1]\n cnt += pc[i][0]\n rem.discard(i)\n \n if sum < g:\n u = max(rem)\n n = min(pc[u][0], -( -(g-sum)//((u+1)*100) ))\n cnt += n\n sum += n*(u+1)*100\n \n if sum >= g:\n ans = min(ans, cnt)\n \n\nprint(ans)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s202478422', 's999813981', 's777504699']
[3316.0, 3700.0, 3064.0]
[22.0, 30.0, 25.0]
[862, 650, 490]
p03290
u973840923
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["from math import ceil\n\nD, G = [int(t) for t in input().split()]\np = []\nc = []\nfor i in range(D):\n p_, c_ = [int(t) for t in input().split()]\n p.append(p_)\n c.append(c_)\n\nprint(p,c)\n\ndef solve(G, i):\n \n if i <= 0:\n return float('inf')\n \n n = min(ceil(G / (100 * i)), p[i - 1])\n s = 100 * i * n\n \n if n == p[i - 1]:\n s += c[i - 1]\n if G > s:\n n += solve(G - s, i - 1)\n return min(n, solve(G, i - 1))\n\nprint(solve(G, D))", "from math import ceil\nD,G = map(int,input().split())\nlist = [list(map(int,input().split())) for _ in range(D)]\n\ndef dfs(G,i):\n if i <= 0:\n return float('inf')\n n = min(ceil(G/(100*i)),list[i-1][0])\n s = 100*i*n\n if n == list[i-1][0]:\n s += list[i-1][1]\n if G > s:\n n += dfs(G-s,i-1)\n return min(n,dfs(G,i-1))\n\nprint(dfs(G,D))"]
['Wrong Answer', 'Accepted']
['s389625271', 's182146430']
[3064.0, 3064.0]
[19.0, 19.0]
[730, 364]
p03290
u983918956
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['import math as m\nfrom fractions import gcd\nD,G = map(int,input().split())\ninfo = [list(map(int,input().split())) for i in range(D)]\ncm = 1\nfor p,c in info:\n cm *= p\nL = []\nfor i in range(1,D+1):\n p = info[i-1][0]\n c = info[i-1][1]\n L.append([cm*100*i + c, i, p, c])\ngoal = G\ncount = 0\n\nL.sort()\n\n\n\nfor i in range(D-1,-1,-1):\n iscore = 100 * L[i][1] * L[i][2] + L[i][3]\n if goal - iscore >= 0:\n goal -= iscore\n count += L[i][2]\n if goal == 0:\n break\n\n\n\n elif goal - iscore < 0:\n adopt = 100\n for k in range(i,-1,-1):\n score = 100 * L[k][1] * L[k][2] + L[k][3]\n if goal - score <= 0:\n j = min(m.ceil(goal/(100 * L[k][1])),L[k][2])\n if j < adopt:\n adopt = j\n count += adopt\n break\nprint(count)', 'import math as m\nfrom fractions import gcd\nD,G = map(int,input().split())\ninfo = [list(map(int,input().split())) for i in range(D)]\na = info[0][0]\nL = []\nfor i in range(1,D):\n b = info[i][0]\n lcm = (a * b) // gcd(a,b)\n a = lcm\nfor i in range(1,D+1):\n p = info[i-1][0]\n c = info[i-1][1]\n L.append([lcm*100*i + c, i, p, c])\ngoal = G\ncount = 0\n\nL.sort()\n\n\n\nfor i in range(D-1,-1,-1):\n iscore = 100 * L[i][1] * L[i][2] + L[i][3]\n if goal - iscore >= 0:\n goal -= iscore\n count += L[i][2]\n if goal == 0:\n break\n\n\n\n elif goal - iscore < 0:\n adopt = 100\n for k in range(i,-1,-1):\n score = 100 * L[k][1] * L[k][2] + L[k][3]\n if goal - score <= 0:\n j = min(m.ceil(goal/(100 * L[k][1])),L[k][2])\n if j < adopt:\n adopt = j\n count += adopt\n break\nprint(count)', 'import math as m\nD,G = map(int, input().split())\ninfo = [list(map(int, input().split())) for i in range(D)]\ndef bfs(list_hoge=[[0,[]]],depth=0):\n queue = []\n for e in list_hoge:\n for b in [0,1]:\n if b == 0:\n score = e[0]\n copy = e[1][:]\n queue.append([score,copy])\n elif b == 1:\n score = e[0] + 100*(depth+1)*info[depth][0] + info[depth][1]\n copy = e[1][:]\n copy.append(depth)\n queue.append([score,copy])\n list_hoge = queue[:]\n if depth == len(info)-1:\n return list_hoge\n return bfs(list_hoge,depth+1)\nres = bfs()\nans = float("inf")\nfor e in res:\n solved = 0\n for i in range(len(e[1])):\n solved += info[e[1][i]][0]\n print(solved)\n if e[0] >= G:\n if solved < ans:\n ans = solved\n continue\n for i in range(D-1,-1,-1):\n if not i in e[1]:\n nec = G-e[0]\n haiten = 100*(i+1)\n add_solve = m.ceil(nec/haiten)\n total_solved = solved + m.ceil(nec/haiten)\n if add_solve >= info[i][0]:\n break\n if total_solved < ans:\n ans = total_solved\nprint(ans)', 'D, G = map(int,input().split())\npc = [list(map(int,input().split())) for _ in range(D)]\n\ncs = [100*(i+1)*p + c for i, (p, c) in enumerate(pc)]\nans = float("inf")\n\nfor i in range(1<<D):\n flag = [False] * D\n score = 0\n num = 0\n for j in range(D):\n \n if (i >> j) & 1:\n flag[j] = True\n score += cs[j]\n num += pc[j][0]\n\n if score >= G:\n ans = min(ans, num)\n continue\n\n last = -1\n for j in range(D)[::-1]:\n if not flag[j]:\n last = j\n break\n\n for _ in range(pc[j][0]-1):\n score += 100*(j+1)\n num += 1\n if score >= G:\n ans = min(ans, num)\n break\n\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s078050900', 's361645269', 's615391518', 's428400476']
[5304.0, 5600.0, 3700.0, 3064.0]
[40.0, 52.0, 24.0, 46.0]
[1337, 1399, 1240, 727]
p03290
u985929170
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = map(int,input().split())\n\nli = [list(map(int,input().split())) for _ in range(D)]\n\n\nten = 0\nc = 0\nkei = 0\n\nfor i,k in enumerate(li[::-1]):\n for j in range(k[0]):\n ten += 100*(D-i)\n c+=1\n if j==k[0]-1:\n ten += k[1]\n if ten>=G:\n kei = c\n break\n else:continue\n break\n \nnum_min = 1001\nten2 = 0\n\nfor i in range(2**D):\n num_i = 0\n ten_i = 0\n for j in range(D):\n if (i>>j) & 1:\n num_i += li[j][0]\n ten_i += li[j][1]\n if ten_i < G:continue\n if num_i <= num_min:\n num_min=num_i\n ten2 = ten_i\n\nif num_min < c:\n print(num_min)\nelse:print(c)', "[D,G],*li = [list(map(int,i.split())) for i in open(0)]\n\nans = float('inf')\n\ndef dfs(i,ten,num,p):\n global ans\n if i==D:\n if ten >= G:\n ans = min(ans,num)\n else:\n for q in p:\n for r in range(li[q][0]):\n ten += (q+1)*100\n num += 1\n if r==li[q][0]:\n ten += li[q][1]\n if ten >= G:\n ans = min(ans,num)\n break\n else:continue\n break\n else:\n dfs(i+1,ten+(i+1)*100*li[i][0]+li[i][1],num+li[i][0],p)\n dfs(i+1,ten,num,[i]+p)\ndfs(0,0,0,[])\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s118114905', 's826398748']
[9244.0, 9180.0]
[31.0, 106.0]
[670, 688]
p03290
u985949234
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
["D, G = map(int, input().split())\ngrid = [[0,0]]\nfor i in range(D):\n p,c = map(int, input().split())\n grid.append([p,c])\n\nimport itertools\nkumi = list(itertools.product([0,1], repeat=D))\nanls = []\nfans = float('inf')\nfor item in kumi:\n count = 0\n ans = 0\n k = 0\n score = 0\n for i in item:\n count += 1\n if i == 1:\n score += grid[count][0]*100*count + grid[count][1]\n ans += grid[count][0]\n else:\n k = count\n\n if G <= score :\n fans = min(fans,ans)\n elif score+(k*100)*(grid[k][0]-1) >= G :\n a = int((G-score)/(k*100))\n if score+a*k*100=G:\n ans += a\n else:\n ans += (a+1)\n fans = min(fans,ans)\nif fans != float('inf'):\n fans = int(fans)\nprint(fans)", "D, G = map(int, input().split())\ngrid = [[0,0]]\nfor i in range(D):\n p,c = map(int, input().split())\n grid.append([p,c])\n\nimport itertools\nkumi = list(itertools.product([0,1], repeat=D))\nanls = []\nfans = float('inf')\nfor item in kumi:\n count = 0\n ans = 0\n k = 0\n score = 0\n for i in item:\n count += 1\n if i == 1:\n score += grid[count][0]*100*count + grid[count][1]\n ans += grid[count][0]\n else:\n k = count\n\n if G <= score :\n fans = min(fans,ans)\n elif score+(k*100)*(grid[k][0]-1) >= G :\n a = int((G-score)/(k*100))\n if score+a*k*100==G:\n ans += a\n else:\n ans += (a+1)\n fans = min(fans,ans)\nif fans != float('inf'):\n fans = int(fans)\nprint(fans)\n\n"]
['Runtime Error', 'Accepted']
['s808434979', 's532454791']
[3064.0, 3188.0]
[18.0, 22.0]
[818, 821]
p03290
u993435350
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D,G = map(int,input().split())\nPC = []\n\nL = []\n\nt = 10 ** 9\nm = 0\n\nfor i in range(1,D + 1):\n p,c = map(int,input().split())\n s = 0\n pc = []\n for j in range(p):\n s += i * 100\n if j == p - 1:\n s += c\n L.append([j + 1,s])\n if s >= G and j + 1 < t:\n t = j + 1\n pc.append([j + 1,s])\n PC.append(pc)\n\ndef recur(problems):\n\u3000\n if len(problems) == D:\n ans = 10 ** 9\n score = 0\n times = 0\n \n for j in range(D):\n if problems[j] == 1:\n score += L[j][1]\n times += L[j][0]\n \n if score >= G:\n ans = min(ans,times)\n return ans\n \n \n else:\n remain = G - score\n if remain <= max([L[i][1] for i in range(D) if problems[i] == 0]):\n for k in range(D):\n if problems[k] == 0:\n for l in range(len(PC[k])):\n if remain <= PC[k][l][1] and ans >= PC[k][l][0]:\n ans = PC[k][l][0]\n ans += times\n return ans\n else:\n return 10 ** 9\n \n else:\n \n ret1 = recur(problems + [1])\n \n ret2 = recur(problems + [0])\n \n return min(ret1,ret2)\n\nprint(recur([]))', 'import math\nD, G = map(int, input().split())\n\nPC = []\nfor _ in range(D):\n p, c = map(int, input().split())\n PC.append([p, c])\n\nans = 10 ** 9\n\n\nfor i in range(2 ** D):\n score = 0\n time = 0\n maxj = -1\n \n for j in range(D):\n \n if ((i >> j) & 1):\n score += (j + 1) * PC[j][0] * 100 + PC[j][1]\n time += PC[j][0]\n \n \n else:\n maxj = max(maxj,j)\n \n if maxj == -1:\n ans = min(ans, time)\n \n elif score + (maxj + 1) * (PC[maxj][0] - 1) * 100 >= G:\n \n \n time += max(0, math.ceil((G - score) / (maxj + 1) / 100))\n \n ans = min(ans, time)\n\nprint(ans)\n\n']
['Runtime Error', 'Accepted']
['s564133793', 's940191804']
[3064.0, 3064.0]
[18.0, 24.0]
[1395, 1337]
p03290
u994064513
2,000
1,048,576
A programming competition site _AtCode_ provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user of AtCode has a value called _total score_. The total score of a user is the sum of the following two elements: * Base score: the sum of the scores of all problems solved by the user. * Perfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D). Takahashi, who is the new user of AtCode, has not solved any problem. His objective is to have a total score of G or more points. At least how many problems does he need to solve for this objective?
['D, G = [int(s) for s in input().split()]\nproblems = [[int(s) for s in input().split()] for _ in range(D)]\n\nresult = 10 ** 8\n\nfor i in range(2 ** D):\n cnt_problem = 0\n cnt_score = 0\n for j in range(D):\n if i << j:\n cnt_score += problems[j][1] + 100 * (j + 1) * problems[j][0]\n cnt_problem += problems[j][0]\n\n for j in reversed(range(D)):\n if not i << j:\n for k in range(1, problems[j][0]):\n if cnt_score >= G:\n break\n else:\n cnt_score += problems[j][1]\n cnt_problem += 1\n result = min(cnt_problem, result)\n\nprint(result)\n', 'D, G = [int(s) for s in input().split()]\nproblems = [[int(s) for s in input().split()] for _ in range(D)]\n\nresult = 10 ** 8\n\nfor i in range(2 ** D):\n cnt_problem = 0\n cnt_score = 0\n for j in range(D):\n if i >> j & 1:\n cnt_score += problems[j][1] + 100 * (j + 1) * problems[j][0]\n cnt_problem += problems[j][0]\n\n for j in reversed(range(D)):\n if not i >> j & 1:\n for _ in range(problems[j][0]):\n if cnt_score >= G:\n break\n else:\n cnt_score += 100 * (j + 1)\n cnt_problem += 1\n result = min(cnt_problem, result)\n\nprint(result)\n']
['Wrong Answer', 'Accepted']
['s154116506', 's183818440']
[3064.0, 3064.0]
[26.0, 173.0]
[669, 673]
p03291
u023229441
2,000
1,048,576
The _ABC number_ of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions: * 1 ≤ i < j < k ≤ |T| (|T| is the length of T.) * T_i = `A` (T_i is the i-th character of T from the beginning.) * T_j = `B` * T_k = `C` For example, when T = `ABCBC`, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3. You are given a string S. Each character of S is `A`, `B`, `C` or `?`. Let Q be the number of occurrences of `?` in S. We can make 3^Q strings by replacing each occurrence of `?` in S with `A`, `B` or `C`. Find the sum of the ABC numbers of all these strings. This sum can be extremely large, so print the sum modulo 10^9 + 7.
['\n# if n-r<r: r=n-r\n# if r == 0: return 1\n# if r == 1: return n\n# \n\n# denominator = [k + 1 for k in range(r)]\n# \n# for p in range(2,r+1):\n\n\n# offset = (n - r) % p\n# for k in range(p-1,r,p):\n# numerator[k - offset] /= pivot\n\n# \n# result = 1\n# for k in range(r):\n# if numerator[k] > 1:\n# result *= int(numerator[k]) %mod\n# \n# return result % mod\n\nA=list(input())\nn=len(A)\nmod=10**9+7\nans=0\nnuma= A[0]=="A" \nnuma_= A[0]=="?"\nnumc=A[2:].count("C")\nnumc_= A[2:].count("?")\n\nfor i in range(1,n-1):\n #print(numa,numa_,numc,numc_)\n apro=cpro=0\n if A[i]=="B" or A[i]=="?":\n # for k in range(numa_+1):\n \n # for k in range(numc_+1):\n # cpro+= (((C(numc_,k)*pow(2,numc_-k,mod))%mod)*(numc+k))%mod\n \n apro= (3*numa+numa_)*3**(numa_-1)\n cpro= (3*numc+numc_)*3**(numc_-1)\n ans+= (apro*cpro)%mod\n ans%=mod\n if A[i] == "A":\n numa+=1\n if A[i]=="?":\n numa_+=1\n if A[i+1] =="C":\n numc-=1\n if A[i+1]=="?":\n numc_-=1\nprint(ans)\n', '\n# if n-r<r: r=n-r\n# if r == 0: return 1\n# if r == 1: return n\n# \n\n# denominator = [k + 1 for k in range(r)]\n# \n# for p in range(2,r+1):\n\n\n# offset = (n - r) % p\n# for k in range(p-1,r,p):\n# numerator[k - offset] /= pivot\n\n# \n# result = 1\n# for k in range(r):\n# if numerator[k] > 1:\n# result *= int(numerator[k]) %mod\n# \n# return result % mod\n\nA=list(input())\nn=len(A)\nmod=10**9+7\nans=0\nnuma= A[0]=="A" \nnuma_= A[0]=="?"\nnumc=A[2:].count("C")\nnumc_= A[2:].count("?")\n\nfor i in range(1,n-1):\n #print(numa,numa_,numc,numc_)\n apro=cpro=0\n if A[i]=="B" or A[i]=="?":\n # for k in range(numa_+1):\n \n # for k in range(numc_+1):\n # cpro+= (((C(numc_,k)*pow(2,numc_-k,mod))%mod)*(numc+k))%mod\n \n apro= ((3*numa+numa_)*pow(3,(numa_-1),mod))%mod\n cpro= ((3*numc+numc_)*pow(3,(numc_-1),mod))%mod\n ans+= (apro*cpro)%mod\n ans%=mod\n if A[i] == "A":\n numa+=1\n if A[i]=="?":\n numa_+=1\n if A[i+1] =="C":\n numc-=1\n if A[i+1]=="?":\n numc_-=1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s302562969', 's059012693']
[10380.0, 10360.0]
[2206.0, 463.0]
[1373, 1401]
p03291
u065079240
2,000
1,048,576
The _ABC number_ of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions: * 1 ≤ i < j < k ≤ |T| (|T| is the length of T.) * T_i = `A` (T_i is the i-th character of T from the beginning.) * T_j = `B` * T_k = `C` For example, when T = `ABCBC`, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3. You are given a string S. Each character of S is `A`, `B`, `C` or `?`. Let Q be the number of occurrences of `?` in S. We can make 3^Q strings by replacing each occurrence of `?` in S with `A`, `B` or `C`. Find the sum of the ABC numbers of all these strings. This sum can be extremely large, so print the sum modulo 10^9 + 7.
['S = input()\nN = len(S)\nmod = 10**9+7\nnumofA = 0\nnumofAB = 0\nnumofABC = 0\nnumofquestion = 0\nfor i in range(N):\n if S[i] == "?":\n numofABC = (numofABC*3+numofAB) % mod\n numofAB = (numofAB*3+numofA) % mod\n numofA = (numofA * 3 + 1) % mod\n numofquestion += 1\n elif S[i] == "C":\n numofABC = (numofAB+numofABC) % mod\n elif S[i] == "B":\n numofAB = (numofAB + numofA) % mod\n else:\n numofA += (numofquestion**3) % mod\nprint(numofABC)\n', 'S = input()\nN = len(S)\nmod = 10**9+7\nnumofA = 0\nnumofAB = 0\nnumofABC = 0\nnumofquestion = 1\nfor i in range(N):\n if S[i] == "?":\n numofABC = (numofABC*3+numofAB) % mod\n numofAB = (numofAB*3+numofA) % mod\n numofA = (numofquestion + numofA*3) % mod\n numofquestion = (numofquestion * 3) % mod\n elif S[i] == "C":\n numofABC = (numofAB+numofABC) % mod\n elif S[i] == "B":\n numofAB = (numofAB + numofA) % mod\n else:\n numofA = (numofquestion + numofA) % mod\nprint(numofABC)\n']
['Wrong Answer', 'Accepted']
['s561085030', 's061029378']
[3188.0, 3188.0]
[85.0, 96.0]
[486, 524]
p03291
u068400994
2,000
1,048,576
The _ABC number_ of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions: * 1 ≤ i < j < k ≤ |T| (|T| is the length of T.) * T_i = `A` (T_i is the i-th character of T from the beginning.) * T_j = `B` * T_k = `C` For example, when T = `ABCBC`, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3. You are given a string S. Each character of S is `A`, `B`, `C` or `?`. Let Q be the number of occurrences of `?` in S. We can make 3^Q strings by replacing each occurrence of `?` in S with `A`, `B` or `C`. Find the sum of the ABC numbers of all these strings. This sum can be extremely large, so print the sum modulo 10^9 + 7.
["# coding: utf-8\n# Your code here!\n\nMOD = 1000000007\nS = input()\n\ndef add(a,b):\n a += b\n if a >= MOD:\n a -= MOD\n return a\n\ndp = [[0 for i in range(5)] for j in range(2000000)]\n\ndp[0][0] = 1\n\nfor i in range(len(S)):\n for j in range(4):\n if S[i] == '?':\n dp[i+1][j] = add(dp[i+1][j], dp[i][j] * 3 % MOD)\n else:\n dp[i+1][j] = add(dp[i+1][j], dp[i][j])\n if S[i] == 'A' or S[i] == '?':\n dp[i+1][1] = add(dp[i+1][1], dp[i][0])\n if S[i] == 'B' or S[i] == '?':\n dp[i+1][2] = add(dp[i+1][2], dp[i][1])\n if S[i] == 'C' or S[i] == '?':\n dp[i+1][3] = add(dp[i+1][3], dp[i][2])\n\nprint(dp[len(S)][3])", "# coding: utf-8\n# Your code here!\n\nMOD = 1000000007\nS = input()\n\ndef add(a,b):\n a += b\n if a >= MOD:\n a -= MOD\n return a\n\ndp = [[0 for i in range(5)] for j in range(200000)]\n\ndp[0][0] = 1\n\nfor i in range(len(S)):\n for j in range(4):\n if S[i] == '?':\n dp[i+1][j] = add(dp[i+1][j], dp[i][j] * 3 % MOD)\n else:\n dp[i+1][j] = add(dp[i+1][j], dp[i][j])\n if S[i] == 'A' or S[i] == '?':\n dp[i+1][1] = add(dp[i+1][1], dp[i][0])\n if S[i] == 'B' or S[i] == '?':\n dp[i+1][2] = add(dp[i+1][2], dp[i][1])\n if S[i] == 'C' or S[i] == '?':\n dp[i+1][3] = add(dp[i+1][3], dp[i][2])\n\nprint(dp[len(S)][3])"]
['Time Limit Exceeded', 'Accepted']
['s211812364', 's092144859']
[305288.0, 45688.0]
[2126.0, 744.0]
[670, 669]
p03291
u077337864
2,000
1,048,576
The _ABC number_ of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions: * 1 ≤ i < j < k ≤ |T| (|T| is the length of T.) * T_i = `A` (T_i is the i-th character of T from the beginning.) * T_j = `B` * T_k = `C` For example, when T = `ABCBC`, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3. You are given a string S. Each character of S is `A`, `B`, `C` or `?`. Let Q be the number of occurrences of `?` in S. We can make 3^Q strings by replacing each occurrence of `?` in S with `A`, `B` or `C`. Find the sum of the ABC numbers of all these strings. This sum can be extremely large, so print the sum modulo 10^9 + 7.
['def get_input(inp):\n li = inp.split("\\n")\n\n def inner():\n return li.pop(0)\n return inner\n\nINPUT="""????C?????B??????A???????"""\ninput = get_input(INPUT)\n\ns = input().strip()\nMOD = pow(10, 9) + 7\n\n\n\n\ndp = [[0 for _ in range(len(s) + 1)] for _ in range(4)]\ndp[0][0] = 1\n\nfor i, _s in enumerate(s):\n if _s == \'?\':\n dp[0][i+1] += dp[0][i] * 3 % MOD\n dp[1][i+1] += dp[1][i] * 3 % MOD\n dp[2][i+1] += dp[2][i] * 3 % MOD\n dp[3][i+1] += dp[3][i] * 3 % MOD\n dp[0][i+1] %= MOD\n dp[1][i+1] %= MOD\n dp[2][i+1] %= MOD\n dp[3][i+1] %= MOD\n else:\n dp[0][i+1] += dp[0][i]\n dp[1][i+1] += dp[1][i]\n dp[2][i+1] += dp[2][i]\n dp[3][i+1] += dp[3][i]\n dp[0][i+1] %= MOD\n dp[1][i+1] %= MOD\n dp[2][i+1] %= MOD\n dp[3][i+1] %= MOD\n if _s == \'A\' or _s == \'?\':\n dp[1][i+1] += dp[0][i]\n dp[1][i+1] %= MOD\n if _s == \'B\' or _s == \'?\':\n dp[2][i+1] += dp[1][i]\n dp[2][i+1] %= MOD\n if _s == \'C\' or _s == \'?\':\n dp[3][i+1] += dp[2][i]\n dp[3][i+1] %= MOD\n\nprint(dp[3][-1])\n', "s = input().strip()\nMOD = pow(10, 9) + 7\n\n\n\n\ndp = [[0 for _ in range(len(s) + 1)] for _ in range(4)]\ndp[0][0] = 1\n\nfor i, _s in enumerate(s):\n if _s == '?':\n dp[0][i+1] += dp[0][i] * 3 % MOD\n dp[1][i+1] += dp[1][i] * 3 % MOD\n dp[2][i+1] += dp[2][i] * 3 % MOD\n dp[3][i+1] += dp[3][i] * 3 % MOD\n dp[0][i+1] %= MOD\n dp[1][i+1] %= MOD\n dp[2][i+1] %= MOD\n dp[3][i+1] %= MOD\n else:\n dp[0][i+1] += dp[0][i]\n dp[1][i+1] += dp[1][i]\n dp[2][i+1] += dp[2][i]\n dp[3][i+1] += dp[3][i]\n dp[0][i+1] %= MOD\n dp[1][i+1] %= MOD\n dp[2][i+1] %= MOD\n dp[3][i+1] %= MOD\n if _s == 'A' or _s == '?':\n dp[1][i+1] += dp[0][i]\n dp[1][i+1] %= MOD\n if _s == 'B' or _s == '?':\n dp[2][i+1] += dp[1][i]\n dp[2][i+1] %= MOD\n if _s == 'C' or _s == '?':\n dp[3][i+1] += dp[2][i]\n dp[3][i+1] %= MOD\n\nprint(dp[3][-1])\n"]
['Wrong Answer', 'Accepted']
['s213323135', 's381831309']
[3192.0, 19168.0]
[18.0, 387.0]
[1212, 1052]
p03291
u089032001
2,000
1,048,576
The _ABC number_ of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions: * 1 ≤ i < j < k ≤ |T| (|T| is the length of T.) * T_i = `A` (T_i is the i-th character of T from the beginning.) * T_j = `B` * T_k = `C` For example, when T = `ABCBC`, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3. You are given a string S. Each character of S is `A`, `B`, `C` or `?`. Let Q be the number of occurrences of `?` in S. We can make 3^Q strings by replacing each occurrence of `?` in S with `A`, `B` or `C`. Find the sum of the ABC numbers of all these strings. This sum can be extremely large, so print the sum modulo 10^9 + 7.
['S = input()\n\nmax_S = 10**9 + 7\n\nN_Q = S.count("?")\nN_C = S.count("C")\n\nt_A = 0\nt_Q = 0\nif(S[0:1] == "C"):\n t_C = N_C - 1\nelse:\n t_C = N_C\n\nS_list = [{"bA": t_A, "bQ": t_Q, "aC": t_C, "aQ": N_Q - t_Q}]\nfor i in range(1, len(S)):\n if(S[i - 1:i] == "A"):\n t_A += 1\n elif(S[i - 1:i] == "?"):\n t_Q += 1\n\n ba_dic = {}\n ba_dic["bA"] = t_A\n ba_dic["bQ"] = t_Q\n if(S[i:i + 1] == "?"):\n ba_dic["aQ"] = N_Q - t_Q - 1\n else:\n ba_dic["aQ"] = N_Q - t_Q\n if(S[i:i + 1] == "C"):\n t_C -= 1\n ba_dic["aC"] = t_C\n\n S_list.append(ba_dic)\n\nans = 0\nfor i in range(len(S)):\n if(S[i:i + 1] == "A" or S[i:i + 1] == "C"):\n continue\n\n bA = S_list[i]["bA"]\n bQ = S_list[i]["bQ"]\n aC = S_list[i]["aC"]\n aQ = S_list[i]["aQ"]\n\n tmp = 9 * bA * aC + bQ * aQ + 3 * (bA * aQ + bQ * aC)\n ans += tmp * int(3**(bQ + aQ - 2))\n ans = ans % max_S\n\nprint(ans)', 'S = input()\n\nmax_S = 10**9 + 7\n\nN_Q = S.count("?")\nN_C = S.count("C")\n\nt_A = 0\nt_Q = 0\nif(S[0:1] == "C"):\n t_C = N_C - 1\nelse:\n t_C = N_C\n\nS_list = [{"bA": t_A, "bQ": t_Q, "aC": t_C, "aQ": N_Q - t_Q}]\nfor i in range(1, len(S)):\n if(S[i - 1:i] == "A"):\n t_A += 1\n elif(S[i - 1:i] == "?"):\n t_Q += 1\n\n ba_dic = {}\n ba_dic["bA"] = t_A\n ba_dic["bQ"] = t_Q\n if(S[i:i + 1] == "?"):\n ba_dic["aQ"] = N_Q - t_Q - 1\n else:\n ba_dic["aQ"] = N_Q - t_Q\n if(S[i:i + 1] == "C"):\n t_C -= 1\n ba_dic["aC"] = t_C\n\n S_list.append(ba_dic)\n\nans = 0\nfor i in range(len(S)):\n if(S[i:i + 1] == "A" or S[i:i + 1] == "C"):\n continue\n\n bA = S_list[i]["bA"]\n bQ = S_list[i]["bQ"]\n aC = S_list[i]["aC"]\n aQ = S_list[i]["aQ"]\n\n tmp = 9 * bA * aC + bQ * aQ + 3 * (bA * aQ + bQ * aC)\n kk = tmp * int(3**(bQ + aQ - 2))\n ans = ans % max_S\n\nprint(ans)', 'S = input()\n\nd = [0, 0, 0, 1]\n\nmax_ans = 10**9 + 7\n\nfor c in reversed(S):\n # print(c, d)\n m = [c == "A", c == "B", c == "C", c == "?"]\n if(m[3] is True):\n tmp = 3\n else:\n tmp = 1\n\n for j in range(3):\n d[j] = (tmp * d[j] + int(m[j] or m[3]) * d[j + 1]) % max_ans\n d[3] = (tmp * d[3]) % max_ans\n\nprint(d[0])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s580098166', 's860067430', 's810409925']
[40652.0, 41144.0, 3188.0]
[2106.0, 2106.0, 300.0]
[918, 916, 344]