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
|
---|---|---|---|---|---|---|---|---|---|---|
p02683 | u233254147 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\n\nn, m, x = list(map(int, input().split()))\nall_list = []\nfor i in range(n):\n tmp = list(map(int, input().split()))\n all_list.append(tmp)\n\nok = False\ncur_price = (10 ** 5) * n + 1\nfor i in range(1, n + 1):\n answers = list(itertools.combinations(range(n), i))\n # print(answers)\n for ans_list in answers:\n sum_list = [0] * (m + 1)\n print(sum_list)\n for ans in ans_list:\n # print(all_list[int(ans[0])])\n sum_list = [a + b for a, b in zip(sum_list, all_list[int(ans)])]\n # print(sum_list)\n if min(sum_list[1:]) >= x:\n if sum_list[0] < cur_price:\n cur_price = sum_list[0]\n ok = True\n\nif ok:\n print(cur_price)\nelse:\n print(-1)\n', 'import itertools\n\nn, m, x = list(map(int, input().split()))\nall_list = []\nfor i in range(n):\n tmp = list(map(int, input().split()))\n all_list.append(tmp)\n\nok = False\ncur_price = (10 ** 5) * n + 1\nfor i in range(1, n + 1):\n answers = list(itertools.combinations(range(n), i))\n # print(answers)\n for ans_list in answers:\n sum_list = [0] * (m + 1)\n # print(sum_list)\n for ans in ans_list:\n # print(all_list[int(ans[0])])\n sum_list = [a + b for a, b in zip(sum_list, all_list[int(ans)])]\n # print(sum_list)\n if min(sum_list[1:]) >= x:\n if sum_list[0] < cur_price:\n cur_price = sum_list[0]\n ok = True\n\nif ok:\n print(cur_price)\nelse:\n print(-1)\n'] | ['Wrong Answer', 'Accepted'] | ['s835549821', 's652821985'] | [9292.0, 9328.0] | [59.0, 50.0] | [756, 758] |
p02683 | u234189749 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\nN,M,X = map(int,input().split())\nA = [list(map(int,input().split())) for i in range(N)]\n\nz = [i for i in range(1, N)]\nm = [1000000000000000000]\n\nfor i in range(N):\n x = list(itertools.combinations(z,i+1))\n\n for s in x:\n for k in range(1,M+1):\n C = sum(A[j-1][k] for j in s)\n if C < X:\n break\n else:\n m.append(sum(A[o-1][0] for o in s))\nprint(min(m) if min(m)!=1000000000000000000 else -1)', 'import itertools\nN,M,X = map(int,input().split())\nA = [list(map(int,input().split())) for i in range(N)]\n\nz = [i for i in range(1, N)]\nm = [1000000000000000000]\n\nfor i in range(N):\n x = list(itertools.combinations(z,i+1))\n print(x)\n for s in x:\n for k in range(1,M+1):\n C = sum(A[j-1][k] for j in s)\n if C < X:\n break\n else:\n m.append(sum(A[o-1][0] for o in s))\nprint(m)\nprint(min(m) if min(m)!=1000000000000000000 else -1)', 'import itertools\nN,M,X = map(int,input().split())\nA = [list(map(int,input().split())) for i in range(N)]\n\nz = [i for i in range(1, N+1)]\nm = [1000000000000000000]\n\nfor i in range(N):\n x = list(itertools.combinations(z,i+1))\n\n for s in x:\n\n for k in range(1,M+1):\n C = sum(A[j-1][k] for j in s)\n if C < X:\n break\n else:\n m.append(sum(A[o-1][0] for o in s))\n\nprint(min(m) if min(m)!=1000000000000000000 else -1)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s564079134', 's656255821', 's936643788'] | [9340.0, 9300.0, 9500.0] | [41.0, 45.0, 63.0] | [473, 494, 478] |
p02683 | u250795848 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\ndef main():\n n,m,r = map(int, input().split())\n dn = [[0] * m for _ in range(n)]\n \n for i in range(n):\n dn[i][:] = map(int, input().split())\n\n dn = np.array(dn)\n cost = []\n sh = 0\n inf = 10e8\n cost = inf\n k = np.zeros(m+1)\n \n def secom(j,k,cost):\n if j == n:\n \n if np.all(k>=r):\n print(k)\n cost = min(cost,k[0])\n return cost\n else:\n return cost\n \n cost1 = secom(j+1,k,cost)\n k += dn[j]\n cost2 = secom(j+1,k,cost)\n k -= dn[j]\n \n return min(cost1,cost2)\n \n \n cost = secom(0,k,cost)\n if cost == inf:\n print(-1)\n else:\n print(int(cost))\n \n \n\nif __name__ == "__main__":\n main()\n', 'def main():\n n,m,r = map(int, input().split())\n dn = [[0] * m for _ in range(n)]\n \n for i in range(n):\n dn[i][:] = map(int, input().split())\n\n dn = np.array(dn)\n cost = []\n sh = 0\n inf = 10e8\n cost = inf\n k = np.zeros(m+1)\n \n def secom(j,k,cost):\n if j == n:\n \n if np.all(k>=r):\n print(k)\n cost = min(cost,k[0])\n return cost\n else:\n return cost\n \n cost1 = secom(j+1,k,cost)\n k += dn[j]\n cost2 = secom(j+1,k,cost)\n k -= dn[j]\n \n return min(cost1,cost2)\n \n \n cost = secom(0,k,cost)\n if cost == inf:\n print(-1)\n else:\n print(int(cost))\n \n \n\nif __name__ == "__main__":\n main()\n', 'N, M, X = map(int,input().split())\n\nC = list()\nA = list()\nfor i in range(N):\n\ttemp = list(map(int,input().split()))\n\tC.append(temp[0])\n\tA.append(temp[1:])\t\n\n\nMAX = 100000000000\t\n\ndef func(cost,a,i):\n\tif min(a) >= X:\n\t\treturn cost\n\telif i == N:\n\t\treturn MAX\n\ttotal_A = [x+y for (x,y) in zip(a,A[i])]\n \n\treturn min(func(cost + C[i],total_A,i+1),func(cost,a,i+1))\n\t\nans = func(0,[0]*M,0)\n\nif ans == MAX:\n\tprint(-1)\nelse:\n\tprint(ans)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s037342768', 's723078149', 's911062144'] | [27352.0, 9256.0, 9228.0] | [635.0, 25.0, 28.0] | [830, 811, 433] |
p02683 | u257856080 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['from operator import add\nN,M,X = map(int, input().split())\ntmp = [list(map(int,list(input().split()))) for i in range(N)]\nc= []\na = [[] for i in range(N)]\nresult = []\nfor i in range(N):\n c.append(tmp[i][0])\n a[i].extend(tmp[i][1:])\n\nprint(c,a)\nfor bit in range(1 << (N)):\n suma = [0] * M\n disc = [X] * M\n c4i = []\n rsum = 0\n for i in range(N):\n if (bit & (1<<i)):\n suma = map(add,suma,a[i])\n c4i.append(i)\n suma = list(suma)\n if suma >= disc:\n for t in c4i:\n rsum = rsum + c[t]\n result.append(rsum)\n\nif result:\n print(min(result))\nelse:\n print(-1)', 'from operator import add\nN,M,X = map(int, input().split())\ntmp = [list(map(int,list(input().split()))) for i in range(N)]\nc= []\na = [[] for i in range(N)]\nresult = []\nfor i in range(N):\n c.append(tmp[i][0])\n a[i].extend(tmp[i][1:])\n\nfor bit in range(1 << (N)):\n suma = [0] * M\n disc = [X] * M\n c4i = []\n rsum = 0\n for i in range(N):\n if (bit & (1<<i)):\n \n suma = map(add,suma,a[i])\n c4i.append(i)\n suma = list(suma)\n # print(c4i)\n # print(suma,disc)\n # print(suma>=disc)\n flag = True\n for v in range(M):\n if suma[v] < disc[v]:\n flag = False\n if flag:\n for t in c4i:\n rsum = rsum + c[t]\n result.append(rsum)\n# print(result)\nif result:\n print(min(result))\nelse:\n print(-1)'] | ['Wrong Answer', 'Accepted'] | ['s195983639', 's178038257'] | [9208.0, 9284.0] | [49.0, 56.0] | [634, 848] |
p02683 | u266014018 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nN, M, X = map(int, input().split())\nC = []\nA = np.zeros((N, M), dtype=int)\nfor i in range(N):\n c, *a = map(int, input().split())\n C.append(c)\n A[i] = a\n\nS = np.sum(A, axis=0)\nprint(A)\nprint(S)\nif True in (S < X):\n print(-1)\n exit(0)\n\nmlt = [0]*12\nC_ = []\nfor i in range(2**N):\n total = 0\n arr = np.zeros((M,),dtype=int)\n for j in range(N):\n if ((i>>j) & 1) == 1:\n total += C[j]\n arr += A[j]\n if True in (arr < X):\n continue\n C_.append(total)\nprint(min(C_))', 'import numpy as np\nN, M, X = map(int, input().split())\nC = []\nA = np.zeros((N, M), dtype=int)\nfor i in range(N):\n c, *a = map(int, input().split())\n C.append(c)\n A[i] = a\n\nS = np.sum(A, axis=0)\nif True in (S < X):\n print(-1)\n exit(0)\n\nC_ = []\nfor i in range(2**N):\n total = 0\n arr = np.zeros((M,),dtype=int)\n for j in range(N):\n if ((i>>j) & 1) == 1:\n total += C[j]\n arr += A[j]\n if True in (arr < X):\n continue\n C_.append(total)\nprint(min(C_))'] | ['Wrong Answer', 'Accepted'] | ['s169446870', 's745899155'] | [27376.0, 27344.0] | [159.0, 156.0] | [541, 510] |
p02683 | u268822556 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["import itertools\nN, M, X = map(int, input().split())\nbook_lists = [list(map(int, input().split())) for i in range(N)]\nno_skill_flg = True\nfor i in range(1, N+1):\n for j in itertools.combinations(book_lists,i):\n sum_list = [0 for _ in range(M+1)]\n for book_date in j:\n for k, l in enumerate(book_date):\n sum_list[k] += l\n print(sum_list)\n if all([s >= X for s in sum_list[1:]]):\n no_skill_flg = False\n if 'ans' in globals():\n ans = min(ans, sum_list[0])\n else:\n ans = sum_list[0]\nprint(ans if not no_skill_flg else -1)", 'def saiki(i,cost,score_list):\n if i == N:\n if min(score_list) >= X:\n ans.append(cost)\n else:\n temp = [score_list[j]+book_lists[i][j+1] for j in range(M)]\n saiki(i+1,cost,score_list)\n saiki(i+1,cost+book_lists[i][0],temp)\n \nN,M,X = map(int,input().split())\nbook_lists = [list(map(int, input().split())) for _ in range(N)]\nans=[]\nsaiki(0,0,[0]*M)\nprint(min(ans) if len(ans)!=0 else -1)'] | ['Wrong Answer', 'Accepted'] | ['s054462985', 's573247194'] | [9232.0, 9284.0] | [80.0, 31.0] | [637, 428] |
p02683 | u273038590 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,X = map(int,input().split())\n\nC=[]\nA=[]\nfor i in range(n):\n\tt = list(map(int, input().split()))\n\tC.append(t[0])#price of books\n\tA.append(t[1:])#point of books\n\t\nresult = -1 \n\nfor i in range(1<<n):\n\tt = [0] * m \n\tc = 0 \n\t\n\tfor j in range(n):\n\t\tif (i>>j)&1:\n\t\t\tfor k in range(m):\n\t\t\t\tt[k] += A[j][k]\n\t\t\tc += C[j] \n\t\telse:\n\t\t\tpass\n\tif min(t)>=x:\n\t\tresult==min(result, t)\nif result == 10**9:\n\tprint(-1)\nelse:\n\tprint(result)', 'n,m,x = map(int, input().split())\nresult = 10**9\nfor _ in range(n):\n\tbooks=list(map(int, input().split()))\n\tA = A.append(books[0])\n\tC = C.append(books[1:])\nfor i in range(1<<n):\n\tcnt = 0\n\trikaido = [0]*m\n\tfor j in range(n):\n\t\tif (i<<j)&1:\n\t\t\tfor k in range(m):\n\t\t\t\trikaido[k]+=C[j][k]\n\t\t\tcnt += A[j]\n\t\telse:\n\t\t\tpass\n\tif min(rikaido)>=x:\n\t\tresult = min(result, cnt)\nif result == 10*9:\n\tprint(-1)\nelse:\n\tprint(result)', '\nn,m,x = map(int, input().split())\nA=[]\nC=[]\ninf = 10**9\nresult = inf\n#\nfor _ in range(n):\n\tCA = list(map(int, input().split()))\n\tC.append(CA[0])\n\tA.append(CA[1:])\nfor i in range(1<<n):\n\trikaido = [0]*m\n\tcnt = 0\t\n\tfor j in range(n):\n\t\tif (i>>j)&1:\n\t\t\tfor k in range(m):\n\t\t\t\trikaido[k] += A[j][k]\n\t\t\tcnt += C[j]\n\t\telse:\n\t\t\tpass\n\tif min(rikaido)>=x:\n\t\tresult = min(result, cnt)\nif result== inf:\n\tprint(-1)\nelse:\n\tprint(result)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s329121889', 's457132401', 's448673740'] | [9220.0, 9152.0, 9168.0] | [23.0, 25.0, 82.0] | [668, 415, 435] |
p02683 | u273345915 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["def main():\n N,M,X=map(int, input().split())\n A=[list(map(int, input().split())) for _ in range(N)]\n ans=10**10**10\n for i in range(2**N):\n b=i+2**N\n c=0\n l=[0]*M\n ok=True\n for j in range(N):\n if b>>j&1 == 1:\n c+=A[j][0]\n for k in range(M):\n l[k]+=A[j][k+1]\n for x in l:\n if x < X: ok = False \n if ok:\n ans = min(ans, c)\n if ans==10**5*N: print('-1')\n else: print(ans)\n\nif __name__=='__main__':\n main()", "def main():\n N,M,X=map(int, input().split())\n A=[list(map(int, input().split())) for _ in range(N)]\n ans=10**10\n for i in range(2**N):\n b=i+2**N\n c=0\n l=[0]*M\n ok=True\n for j in range(N):\n if b>>j&1 == 1:\n c+=A[j][0]\n for k in range(M):\n l[k]+=A[j][k+1]\n for x in l:\n if x < X: ok = False \n if ok:\n ans = min(ans, c)\n if ans==10**10: print('-1')\n else: print(ans)\n\nif __name__=='__main__':\n main()"] | ['Time Limit Exceeded', 'Accepted'] | ['s449024275', 's560210485'] | [16904.0, 9236.0] | [2206.0, 65.0] | [554, 549] |
p02683 | u279266699 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\nimport numpy as np\nn, m, x = map(int, input().split())\nl = [list(map(int, input().split())) for _ in range(n)]\nl = sorted(l)\nl = np.array(l)\nprint(l)\nans = np.sum(l, 0)[0]\nans_s = np.sum(l, 0)\nif np.any(ans_s[1:] < x):\n print(-1)\n exit()\ncount = 0\nfor i in range(1, m + 1):\n for j in itertools.combinations(l, i):\n tot = np.sum(j, 0)\n if np.all(tot[1:] >= x) and tot[0] < ans:\n ans = tot[0]\n print(int(ans))\n exit()', 'import itertools\nimport numpy as np\nn, m, x = map(int, input().split())\nl = [list(map(int, input().split())) for _ in range(n)]\nl = np.array(l)\nans = np.sum(l, 0)[0]\nans_s = np.sum(l, 0)\nif np.any(ans_s[1:] < x):\n print(-1)\n exit()\nfor i in range(1, n + 1):\n for j in itertools.combinations(l, i):\n tot = np.sum(j, 0)\n if np.all(tot[1:] >= x) and tot[0] < ans:\n ans = tot[0]\nprint(int(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s472941600', 's428010685'] | [27224.0, 27336.0] | [152.0, 156.0] | [488, 425] |
p02683 | u284155299 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["N , M , X = map(int,input().split())\nC = []\nA = []\nfor _ in range(N):\n CA = list(map(int,input().split()))\n C.append(CA[0])\n A.append(CA[1:])\n\nans = float('inf')\nfor i in range(2**N):\n Level = [0]* M\n Cost = 0\n \n for j in range(N):\n if (i>>j)&1:\n Cost += C[j]\n for k in range(M):\n Level[\u200b Cost)\n\nif ans != float('inf'):\n print(ans)\nelse:\n print('-1')", "N , M , X = map(int,input().split())\nC = []\nA = []\nfor _ in range(N):\n CA = list(map(int,input().split()))\n C.append(CA[0])\n A.append(CA[1:])\n\nans = float('inf')\nfor i in range(2**N):\n Level = [0]* M\n Cost = 0\n \n for j in range(N):\n if (i>>j)&1:\n Cost += C[j]\n for k in range(M):\n Level[k] += A[j][k]\n \n if all([Level[l] >= X for l in range(M)]):\n ans = min(ans, Cost)\n\nif ans != float('inf'):\n print(ans)\nelse:\n print('-1')"] | ['Runtime Error', 'Accepted'] | ['s511196802', 's183517710'] | [9072.0, 9172.0] | [22.0, 87.0] | [423, 520] |
p02683 | u284363684 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["# input\nN, M, X = map(int, input().split())\n\nbooks = []\nappend = books.append\nmax_exp = [0] * M\nfor i in range(N):\n\n CA = list(map(int, input().split()))\n\n append(\n {\n 'price': CA[0],\n 'get_exp': CA[1:],\n 'koritsu': sum(CA[1:]) / CA[0]\n }\n )\n for ind, j in enumerate(max_exp):\n max_exp[ind] += CA[ind + 1]\n\nbooks = sorted(\n books,\n key=lambda x: x['koritsu'],\n reverse=True\n)\nbooks = sorted(\n books,\n key=lambda x: x['price']\n)\n\n\nif min(max_exp) < X:\n print(-1)\nelse:\n exps = [0] * M\n price = 0\n\n while min(exps) < X:\n\n price += books[0]['price']\n\n for ind, exp in enumerate(books[0]['get_exp']):\n exps[ind] += exp\n\n del books[0]\n books = sorted(\n books,\n key=lambda x: x['koritsu'],\n reverse=True\n )\n books = sorted(\n books,\n key=lambda x: x['price']\n )\n\n print(price)", "def main():\n N, M, X = [int(x) for x in input().split()]\n Cl, All = [], []\n for i in range(N):\n tmp = [int(x) for x in input().split()]\n Cl.append(tmp[0])\n All.append((tmp[1:]))\n \n min_cost = sum(Cl) + 1\n \n for bit in range(1, 1 << N):\n cost = 0\n \n totalAl = [0]*M\n for i, al in enumerate(All):\n \n if (1 << i) & bit:\n for j, a in enumerate(al):\n totalAl[j] += a\n cost += Cl[i]\n \n check = True\n for a in totalAl:\n if a < X:\n check = False\n if check:\n min_cost = min(min_cost, cost)\n \n if min_cost > sum(Cl):\n print(-1)\n else:\n print(min_cost)\n\n\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s145903035', 's018239013'] | [9220.0, 9248.0] | [24.0, 54.0] | [987, 1222] |
p02683 | u289102924 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n, m, x = map(int, input().split())\nc = [[0]*m] *n\nfor i in range(n):\n c[i] = list(map(int, input().split()))\nans = 1000000\nshoki = [0] * (m + 1)\n\n\n\ndef check(xxx):\n tmp = 0\n for i in range(1,m):\n if x > xxx[i]:\n tmp = 1\n if tmp == 0:\n return True\n else:\n return False\n\ndef tashi(g,h):\n shoki = [0] * (m + 1)\n for i in range(m+1):\n shoki[i] = g[i] + h[i]\n return shoki\n \n\ndef aaa(asum,b):\n if check(asum):\n ans = min(ans, asum[0]) \n return True\n if b == n:\n return False\n if aaa(asum, b+1):\n return check(asum)\n if aaa(tashi(asum,c[b]),b+1):\n return check(asum)\n\n\nif aaa(shoki, 0):\n print(ans)\nelse:\n print(-1)', 'import sys\nsys.setrecursionlimit(10 ** 6)\n\nn,m,x = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(n)]\n\ndef dfs(asum, b):\n global n, m, x\n rst = 10 ** 8\n if b == n:\n if all(asum[i] >= x for i in range(1, m + 1)):\n rst = asum[0]\n else:\n rst = min(rst, dfs(asum, b+1))\n asum2 = tuple(asum[i] + c[b][i] for i in range(m + 1))\n rst = min(rst, dfs(asum2, b+1))\n\n return rst\n\nrst = dfs(tuple([0] * (m + 1)), 0)\nans = rst if rst < 10 ** 8 else -1\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s919719143', 's021839451'] | [9268.0, 9324.0] | [35.0, 34.0] | [733, 534] |
p02683 | u289288647 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\n\nN, M, X = (int(x) for x in input().split())\nval = []\nfor i in range(N):\n exec("c%d = input().split()" % N)\n exec("val.append(c%d)" % N)\n\nexec("tol=[0]*%d" % (M+1))\nval = sorted(val)\nprint(val)\n\n\nfor i in val:\n for j, k in enumerate(i):\n tol[j] += int(k)\n\n for m, l in enumerate(tol[1:]):\n print(l)\n if l < 10:\n continue\n elif m == M -2:\n print(tol[0])\n exit()\nprint("-1")\n \n \n', 'from itertools import product\nN, M, X = map(int, input().split())\n\nval0 = [0]*(M+1)\nans = 10**9\nval = []\nfor _ in range(N):\n val.append(list(map(int, input().split())))\n\nfor i in range(2**N):\n ls = ["+"]*N\n for j in range(len(ls)):\n if (i >> j) & 1:\n ls[j] = "-"\n for m, n in enumerate(ls):\n if n == \'+\':\n val0 = [x + y for (x, y) in zip(val0, val[m])]\n if ans > val0[0]:\n for k, l in enumerate(val0[1:]):\n if l < X:\n break\n elif k == len(val0[1:])-1:\n ans = val0[0]\n val0 = [0]*(M+1)\n \nif ans == 10**9:\n print(-1)\nelse:\n print(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s720299420', 's735725484'] | [27148.0, 9272.0] | [117.0, 72.0] | [472, 659] |
p02683 | u290187182 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["\ndef sumList(index,array):\n if index ==n:\n sumArray.append(array)\n else:\n sumList(index+1,array)\n nextArray =[0]*(m+1)\n for i in range(m+1):\n nextArray[i] +=array[i]+ list[index][i]\n sumList(index+1,nextArray)\n\n\n\nif __name__ == '__main__':\n n,m,x = map(int, input().split())\n\n list = []\n for i in range(n):\n a = [int(i) for i in input().split()]\n list.append(a)\n firstArray = [0] * (m + 1)\n sumArray = []\n sumList(0,firstArray)\n\n min = 100000000\n print(sumArray)\n for i in sumArray:\n amount =0\n count =0\n for j in range(len(i)):\n if j == 0:\n amount =i[j]\n else:\n if i[j] >=x:\n count+=1\n if count == m and min >= amount:\n min = amount\n\n if min == 100000000:\n print(-1)\n else:\n print(min)\n\n\n", "def sumList(index,array):\n if index ==n:\n sumArray.append(array)\n else:\n sumList(index+1,array)\n nextArray =[0]*(m+1)\n for i in range(m+1):\n nextArray[i] +=array[i]+ list[index][i]\n sumList(index+1,nextArray)\n\n\n\nif __name__ == '__main__':\n n,m,x = map(int, input().split())\n\n list = []\n for i in range(n):\n a = [int(i) for i in input().split()]\n list.append(a)\n firstArray = [0] * (m + 1)\n sumArray = []\n sumList(0,firstArray)\n\n min = 100000000\n for i in sumArray:\n amount =0\n count =0\n for j in range(len(i)):\n if j == 0:\n amount =i[j]\n else:\n if i[j] >=x:\n count+=1\n if count == m and min >= amount:\n min = amount\n\n if min == 100000000:\n print(-1)\n else:\n print(min)\n"] | ['Wrong Answer', 'Accepted'] | ['s277122930', 's341001307'] | [12204.0, 10972.0] | [48.0, 42.0] | [912, 889] |
p02683 | u291988695 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\nn,m,x=map(int,input().split())\nl=[[0]]*n\nln=[0]*m\nkan=0\nfor i in range(n):\n l[i]=list(map(int,input().split()))\n for j in range(m+1):\n if j==0:\n kan+=l[i][j]\n else:\n ln[j-1]+=l[i][j]\nif sorted(ln)[0]<x:\n print(-1)\nelse:\n mkan=-1\n for i in range(n):\n itr=itertools.combinations(range(n),i)\n for comb in itr:\n kan=0\n ln=[0]*m\n for j in comb:\n kan+=l[int(j)][0]\n for ii in range(m):\n ln[ii]+=l[int(j)][ii+1]\n if sorted(ln)>=x:\n if mkan==-1 or mkan>kan:\n mkan=kan\n print(mkan)', 'import itertools\nn,m,x=map(int,input().split())\nl=[[0]]*n\nln=[0]*m\nkan=0\nfor i in range(n):\n l[i]=list(map(int,input().split()))\n for j in range(m+1):\n if j==0:\n kan+=l[i][j]\n else:\n ln[j-1]+=l[i][j]\nif sorted(ln)[0]<x:\n print(-1)\nelse:\n mkan=-1\n for i in range(n+1):\n itr=itertools.combinations(range(n),i)\n for comb in itr:\n kan=0\n ln=[0]*m\n for j in comb:\n kan+=l[int(j)][0]\n for ii in range(m):\n ln[ii]+=l[int(j)][ii+1]\n if sorted(ln)[0]>=x:\n if mkan==-1 or mkan>kan:\n mkan=kan\n print(mkan)\n'] | ['Runtime Error', 'Accepted'] | ['s966618487', 's276132047'] | [9260.0, 9256.0] | [23.0, 101.0] | [576, 582] |
p02683 | u297089927 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['from itertools import combinations as co\nn,m,x=map(int,input().split())\nA=[[] for i in range(m)]\nansl=[]\nfor i in range(n):\n A[i].append(map(int,input().split()))\nfor i in range(n):\n for j in range(1,m+1):\n if A[i][j]<x:\n break\n if j==m:\n ansl.append(A[i][0])\n\nif n==1:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor i,j in co(range(n),2):\n for k in range(1,m+1):\n if A[i][k]+A[j][k]<x:\n break\n if k==m:\n ansl.append(A[i][0]+A[j][0])\nif n==2:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor i,j,k in co(range(n),3):\n for l in range(1,m+1):\n if A[i][l]+A[j][l]+A[k][l]<x:\n break\n if l==m:\n ansl.append(A[i][0]+A[j][0]+A[k][0])\nif n==3:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor h,i,j,k in co(range(n),4):\n for l in range(1,m+1):\n if A[h][l]+A[i][l]+A[j][l]+A[k][l]<x:\n break\n if l==m:\n ansl.append(A[h][0]+A[i][0]+A[j][0]+A[k][0])\nif n==4:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor g,h,i,j,k in co(range(n),5):\n for l in range(1,m+1):\n if sum([A[alp][l] for alp in [g,h,i,j,k]])<x:\n break\n if l==m:\n ansl.append(sum([A[alp][0] for alp in [g,h,i,j,k]]))\nif n==5:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor f,g,h,i,j,k in co(range(n),6):\n for l in range(1,m+1):\n if sum([A[alp][l] for alp in [f,g,h,i,j,k]])<x:\n break\n if l==m:\n ansl.append(sum([A[alp][0] for alp in [f,g,h,i,j,k]]))\nif n==6:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor e,f,g,h,i,j,k in co(range(n),7):\n for l in range(1,m+1):\n if sum([A[alp][l] for alp in [e,f,g,h,i,j,k]])<x:\n break\n if l==m:\n ansl.append(sum([A[alp][0] for alp in [e,f,g,h,i,j,k]]))\nif n==7:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor d,e,f,g,h,i,j,k in co(range(n),8):\n for l in range(1,m+1):\n if sum([A[alp][l] for alp in [d,e,f,g,h,i,j,k]])<x:\n break\n if l==m:\n ansl.append(sum([A[alp][0] for alp in [d,e,f,g,h,i,j,k]]))\nif n==8:\n print(min(ansl))\n quit()\nfor c,d,e,f,g,h,i,j,k in co(range(n),9):\n for l in range(1,m+1):\n if sum([A[alp][l] for alp in [c,d,e,f,g,h,i,j,k]])<x:\n break\n if l==m:\n ansl.append(sum([A[alp][0] for alp in [c,d,e,f,g,h,i,j,k]]))\nif n==9:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor b,c,d,e,f,g,h,i,j,k in co(range(n),10):\n for l in range(1,m+1):\n if sum([A[alp][l] for alp in [b,c,d,e,f,g,h,i,j,k]])<x:\n break\n if l==m:\n ansl.append(sum([A[alp][0] for alp in [b,c,d,e,f,g,h,i,j,k]]))\nif n==10:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor a,b,c,d,e,f,g,h,i,j,k in co(range(n),11):\n for l in range(1,m+1):\n if sum([A[alp][l] for alp in [a,b,c,d,e,f,g,h,i,j,k]])<x:\n break\n if l==m:\n ansl.append(sum([A[alp][0] for alp in [a,b,c,d,e,f,g,h,i,j,k]]))\nif n==11:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\nfor a0,a,b,c,d,e,f,g,h,i,j,k in co(range(n),12):\n for l in range(1,m+1):\n if sum([A[alp][l] for alp in [a0,a,b,c,d,e,f,g,h,i,j,k]])<x:\n break\n if l==m:\n ansl.append(sum([A[alp][0] for alp in [a0,a,b,c,d,e,f,g,h,i,j,k]]))\nif n==12:\n print(min(ansl) if len(ansl)!>0 else "-1")\n quit()\n', 'from itertools import combinations as co\nn,m,x=map(int,input().split())\nA=[]\nansl=[]\n\nfor i in range(n):\n A.append(list(map(int,input().split())))\na0,a,b,c,d,e,f,g,h,i,j,k,l=0,0,0,0,0,0,0,0,0,0,0,0,0\nalp=[i,(i,j),(i,j,k),(h,i,j,k),(g,h,i,j,k),(f,g,h,i,j,k),(e,f,g,h,i,j,k),(d,e,f,g,h,i,j,k),(c,d,e,f,g,h,i,j,k),(b,c,d,e,f,g,h,i,j,k),(a,b,c,d,e,f,g,h,i,j,k),(a0,a,b,c,d,e,f,g,h,i,j,k)]\nfor t in range(n):\n for alp[t] in co(range(n),t+1):\n for l in range(1,m+1):\n if sum([A[al][l] for al in alp[t]])<x:\n break\n if l==m:\n ansl.append(sum([A[al][0] for al in alp[t]]))\n if n==t+1:\n print(min(ansl) if len(ansl)>0 else "-1")\n quit()\n\n'] | ['Runtime Error', 'Accepted'] | ['s890034694', 's145220833'] | [9064.0, 9352.0] | [22.0, 53.0] | [3504, 711] |
p02683 | u303344598 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x = map(int,input().split())\nfor i in range(n):\n c.append(list(map(int,input().split())))\nprint(c)\nresult = -1\nfor i in range(2 ** n):\n ct = 0\n t = [0] * m\n for b in range(1, n + 1):\n if i & b > 0:\n ct += c[b - 1][0]\n for j in range(1, m + 1):\n t[j - 1] += c[b - 1][j]\n if result == -1 or ct < result:\n r = 1\n for ti in t:\n if ti < x:\n r = 0\n if r == 1:\n print(ct)\n print(t)\n result = ct\nprint(result)', 'n,m,x = map(int,input().split())\nc = []\na = []\nfor i in range(n):\n l = list(map(int,input().split()))\n c.append(l[0])\n a.append(l[1:])\nresult = -1\nfor i in range(2 ** n):\n ct = 0\n at = [0] * m\n for b in range(1, n + 1):\n bb = 1 << b\n if i & bb > 0:\n ct += c[b - 1]\n for j in range(0, m):\n at[j] += a[b - 1][j]\n if result == -1 or ct < result:\n r = 1\n for ati in at:\n if ati < x:\n r = 0\n if r == 1:\n result = ct\nprint(result)', 'n,m,x = map(int,input().split())\nc = []\na = []\nfor i in range(n):\n l = list(map(int,input().split()))\n c.append(l[0])\n a.append(l[1:])\nresult = -1\nfor i in range(2 ** n):\n ct = 0\n at = [0] * m\n for b in range(0, n):\n bb = 1 << b \n if i & bb > 0:\n ct += c[b]\n for j in range(0, m):\n at[j] += a[b][j]\n if result == -1 or ct < result:\n r = 1\n for ati in at:\n if ati < x:\n r = 0\n if r == 1:\n result = ct\nprint(result)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s448451906', 's562224384', 's479639130'] | [9228.0, 9220.0, 9148.0] | [26.0, 92.0, 94.0] | [466, 480, 469] |
p02683 | u304058693 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n, m, x = map(int, input().split())\na = list(list(map(int, input().split())) for _ in range(n))\n\n#print(n, m, x, a)\n\n\ncost_abl = []\ncost_lis = []\nabl_lis = []\nfor i in range(1 << n):\n cost = 0\n abl_sum = [0] * m\n #print(abl_sum)\n \n for j in range (len(a)):\n mask = 1 << j\n if i & mask:\n cost += a[j][0]\n for k in range(m):\n abl_sum[k] += a[j][k + 1]\n # abl_1 += a[j][1]\n # abl_2 += a[j][2]\n # abl_3 += a[j][3]\n cost_lis.append(cost)\n abl_lis.append(abl_sum)\n #print(bin(i))\nprint(cost_lis, abl_lis)\n\ncost_new_lis = []\nfor i in range(len(abl_lis)):\n if min(abl_lis[i]) >= x:\n cost_new_lis.append(cost_lis[i])\n else:\n pass\n#print(cost_new_lis)\n\nif cost_new_lis == []:\n print(-1)\nelse:\n print(min(cost_new_lis))\n', 'n, m, x = map(int, input().split())\na = list(list(map(int, input().split())) for _ in range(n))\n\n#print(n, m, x, a)\n\n\ncost_abl = []\ncost_lis = []\nabl_lis = []\nfor i in range(1 << n):\n cost = 0\n abl_sum = [0] * m\n #print(abl_sum)\n \n for j in range (len(a)):\n mask = 1 << j\n if i & mask:\n cost += a[j][0]\n for k in range(m):\n abl_sum[k] += a[j][k + 1]\n # abl_1 += a[j][1]\n # abl_2 += a[j][2]\n # abl_3 += a[j][3]\n cost_lis.append(cost)\n abl_lis.append(abl_sum)\n #print(bin(i))\n\n\ncost_new_lis = []\nfor i in range(len(abl_lis)):\n if min(abl_lis[i]) >= x:\n cost_new_lis.append(cost_lis[i])\n else:\n pass\n#print(cost_new_lis)\n\nif cost_new_lis == []:\n print(-1)\nelse:\n print(min(cost_new_lis))\n'] | ['Wrong Answer', 'Accepted'] | ['s420172856', 's113105342'] | [12032.0, 11308.0] | [104.0, 97.0] | [924, 925] |
p02683 | u305349402 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['from itertools import combinations\n \nN, M, X = list(map(int,input().split()))\nA = []\nfor i in range(N):\n A.append(list(map(int,input().split())))\nsum = []\nsubsets=[]\nfor i in range(len(A) + 1):\n for c in combinations(A, i):\n subsets.append(list(c))\n \nfor i in subsets:\n tmp = [0]*(M+1)\n if len(i) == 1:\n sum.append(i[0])\n elif len(i) == 0:\n sum.append([0]*(M+1))\n else:\n for j in i:\n tmp = list(map(lambda a,b: a + b, tmp,j))\n sum.append(tmp)\n \nmin_price = 1000000\n \nfor i in sum:\n t = 0\n for j in range(len(i)):\n if j==0:\n pass\n elif X > i[j]:\n break\n min_price = min(min_price, i[0])\n \nif min_price == 1000000:\n print(-1)\nelse:\n print(min_price) ', 'from itertools import combinations\n \nN, M, X = list(map(int,input().split()))\nA = []\nfor i in range(N):\n A.append(list(map(int,input().split())))\nsum = []\nsubsets=[]\nfor i in range(len(A) + 1):\n for c in combinations(A, i):\n subsets.append(list(c))\n \nprint(subsets)\nfor i in subsets:\n tmp = [0]*6\n if len(i) == 1:\n sum.append(i[0])\n elif len(i) == 0:\n sum.append([0]*6)\n else:\n for j in i:\n tmp = list(map(lambda a,b: a + b, tmp,j))\n sum.append(tmp)\nprint(sum)\n \nmin_price = 1000000\n \nfor i in sum:\n t = 0\n for j in i:\n if X > j:\n t = 1\n if t == 0:\n min_price = min(min_price, i[0])\n \nif min_price == 1000000:\n print(-1)\nelse:\n print(min_price) ', 'from itertools import combinations\n \nN, M, X = list(map(int,input().split()))\nA = []\nfor i in range(N):\n A.append(list(map(int,input().split())))\nsum = []\nsubsets=[]\nfor i in range(len(A) + 1):\n for c in combinations(A, i):\n subsets.append(list(c))\n \nfor i in subsets:\n tmp = [0]*(M+1)\n if len(i) == 1:\n sum.append(i[0])\n elif len(i) == 0:\n sum.append([0]*(M+1))\n else:\n for j in i:\n tmp = list(map(lambda a,b: a + b, tmp,j))\n sum.append(tmp)\n \nmin_price = 101010101010101010101010\n \nfor i in sum:\n t = 0\n for j in range(len(i)):\n if j==0:\n pass\n elif X > i[j]:\n t = 1\n break\n if t == 0\n min_price = min(min_price, i[0])\n \nif min_price == 101010101010101010101010:\n print(-1)\nelse:\n print(min_price) ', 'from itertools import combinations\n \nN, M, X = list(map(int,input().split()))\nA = []\nfor i in range(N):\n A.append(list(map(int,input().split())))\nsum = []\nsubsets=[]\nfor i in range(len(A) + 1):\n for c in combinations(A, i):\n subsets.append(list(c))\n \nfor i in subsets:\n tmp = [0]*(M+1)\n if len(i) == 1:\n sum.append(i[0])\n elif len(i) == 0:\n sum.append([0]*(M+1))\n else:\n for j in i:\n tmp = list(map(lambda a,b: a + b, tmp,j))\n sum.append(tmp)\n \nmin_price = 999999999999999\n \nfor i in sum:\n t = 0\n for j in range(len(i)):\n if j==0:\n pass\n elif X > i[j]:\n t = 1\n break\n if t == 0\n min_price = min(min_price, i[0])\n \nif min_price == 999999999999999:\n print(-1)\nelse:\n print(min_price)', 'from itertools import combinations\n \nN, M, X = list(map(int,input().split()))\nA = []\nfor i in range(N):\n A.append(list(map(int,input().split())))\nsum = []\nsubsets=[]\nfor i in range(len(A) + 1):\n for c in combinations(A, i):\n subsets.append(list(c))\n \nfor i in subsets:\n tmp = [0]*(M+1)\n if len(i) == 1:\n sum.append(i[0])\n elif len(i) == 0:\n sum.append([0]*(M+1))\n else:\n for j in i:\n tmp = list(map(lambda a,b: a + b, tmp,j))\n sum.append(tmp)\n \nmin_price = 10000000000\n \nfor i in sum:\n t = 0\n for j in range(len(i)):\n if j==0:\n pass\n elif X > i[j]:\n t = 1\n break\n if t == 0:\n min_price = min(min_price, i[0])\n \nif min_price == 10000000000:\n print(-1)\nelse:\n print(min_price)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s175870536', 's596562145', 's737334492', 's978987875', 's231542788'] | [12000.0, 13956.0, 9100.0, 9104.0, 11796.0] | [74.0, 90.0, 21.0, 24.0, 65.0] | [706, 696, 764, 745, 738] |
p02683 | u306516971 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\nN, M, X = map(int, input().split())\na = [list(map(int, input().split())) for i in range(N)]\nli = []\nfor i in range(N+1):\n for j in itertools.combinations(range(N), i):\n sm = [0] * (M+1)\n for k in j:\n for l in range(M+1):\n sm[l] += a[k][l]\n if all(y >= X for y in sm[1:M+1]):\n li.append(sm[0])\nif li == []:\n print(-1)\nelse:\n print(min(li))\nprint(li)', 'import itertools\nN, M, X = map(int, input().split())\na = [list(map(int, input().split())) for i in range(N)]\nli = []\nfor i in range(N+1):\n for j in itertools.combinations(range(N), i):\n sm = [0] * (M+1)\n for k in j:\n for l in range(M+1):\n sm[l] += a[k][l]\n if all(y >= X for y in sm[1:M+1]):\n li.append(sm[0])\nif li == []:\n print(-1)\nelse:\n print(min(li))'] | ['Wrong Answer', 'Accepted'] | ['s329283738', 's723931760'] | [9396.0, 9276.0] | [81.0, 81.0] | [432, 422] |
p02683 | u307592354 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['def resolve():\n N,M,X = map(int,input().split())\n CA = [list(map(int,input().split())) for i in range(N)]\n mxc = float(\'inf\')\n for r in range(N+1):\n for cmb in itt.combinations(CA,r):\n cost = 0\n tbl = [0]*M\n for x in cmb:\n cost+=x[0]\n for i in range(M):\n tbl[i]+= x[i+1]\n\n for i in tbl:\n if i < X:\n break\n else:\n mxc = min(cost,mxc)\n \n if mxc == float(\'inf\'):\n print(-1)\n else:\n print(mxc)\n\n\n\nif __name__ == "__main__":\n resolve()', 'import itertools as itt\ndef resolve():\n N,M,X = map(int,input().split())\n CA = [list(map(int,input().split())) for i in range(N)]\n mxc = float(\'inf\')\n for r in range(N+1):\n for cmb in itt.combinations(CA,r):\n cost = 0\n tbl = [0]*M\n for x in cmb:\n cost+=x[0]\n for i in range(M):\n tbl[i]+= x[i+1]\n\n for i in tbl:\n if i < X:\n break\n else:\n mxc = min(cost,mxc)\n \n if mxc == float(\'inf\'):\n print(-1)\n else:\n print(mxc)\n\n\n\nif __name__ == "__main__":\n resolve()\n'] | ['Runtime Error', 'Accepted'] | ['s931969488', 's832432529'] | [9004.0, 9216.0] | [23.0, 52.0] | [640, 665] |
p02683 | u307622233 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["import sys\ninput = sys.stdin.readline\n\n\ndef main():\n n, m, x = map(int, input().split())\n lst = [[int(i) for i in input().split()] for _ in range(n)]\n\n ans = []\n for i in range(1 << n):\n understand = []\n money = 0\n for j in range(n):\n if (i >> j) & 1 == 0:\n continue\n money += lst[0]\n for k in range(m):\n understand[k] += lst[k + 1]\n if all([i >= x for i in understand]):\n ans.append(money)\n\n print(min(ans))\n\n\nif __name__ == '__main__':\n main()\n", "import sys\ninput = sys.stdin.readlinedef\n\n\ndef main():\n n, m, x = map(int, input().split())\n\n MONEY = []\n UNDERSTAND = []\n for i in range(n):\n lst = [int(i) for i in input().split()]\n MONEY.append(lst[0])\n UNDERSTAND.append(lst[1:])\n\n ans = []\n for i in range(1 << n):\n understand = [0] * m\n money = 0\n for j in range(n):\n if (i >> j) & 1 == 0:\n continue\n money += MONEY[j]\n for k in range(m):\n understand[k] += UNDERSTAND[j][k]\n if all([i >= x for i in understand]):\n ans.append(money)\n\n print(min(ans))\n\n\nif __name__ == '__main__':\n main()", "import itertools\nimport sys\ninput = sys.stdin.readline\n\n\ndef main():\n n, m, x = map(int, input().split())\n\n MONEY = []\n UNDERSTAND = []\n for i in range(n):\n lst = [int(i) for i in input().split()]\n MONEY.append(lst[0])\n UNDERSTAND.append(lst[1:])\n\n ans = -1\n for i in range(1 << n):\n understand = [0] * m\n money = 0\n b = [int(i) for i in bin(i)[2:]]\n for select_u, select_m in itertools.compress(zip(UNDERSTAND, MONEY), b[::-1]):\n money += select_m\n for k in range(m):\n understand[k] += select_u[k]\n if all([i >= x for i in understand]):\n if ans == -1:\n ans = money\n else:\n ans = min(ans, money)\n print(ans)\n\n\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s536433980', 's663947605', 's828951871'] | [9216.0, 8992.0, 9108.0] | [26.0, 24.0, 60.0] | [566, 688, 813] |
p02683 | u309120194 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['N, M, X = map(int, input().split())\nC = [(list(map(int, input().split()))) for _ in range(N)]\n \n\nans = 10**10\nfor i in range(2**N):\n U = [0]*(M+1)\n for j in range(N):\n if ((i >> j) & 1):\n for k in range(M+1):\n U[k] += C[j][k]\n \n \n if sum([u >= X for u in U[1:]]) == M:\n ans = min(ans, U[0])\n\nif ans = 10**10: print(-1)\nelse: print(ans)', 'N, M, X = map(int, input().split())\nC = [(list(map(int, input().split()))) for _ in range(N)]\n \n\nans = 10**10\nfor i in range(2**N):\n U = [0]*(M+1)\n for j in range(N):\n if ((i >> j) & 1):\n for k in range(M+1):\n U[k] += C[j][k]\n \n \n if sum([u >= X for u in U[1:]]) == M:\n ans = min(ans, M[0])\n\nif ans == 10**10: print(-1)\nelse: print(ans)\n ', 'N, M, X = map(int, input().split())\nC = [(list(map(int, input().split()))) for _ in range(N)]\n \n\nans = 10**10\nfor i in range(2**N):\n U = [0]*(M+1)\n for j in range(N):\n if ((i >> j) & 1):\n for k in range(M+1):\n U[k] += C[j][k]\n \n \n if sum([u >= X for u in U[1:]]) == M:\n ans = min(ans, U[0])\n\nif ans == 10**10: print(-1)\nelse: print(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s097830653', 's900877339', 's844343625'] | [8896.0, 9156.0, 9204.0] | [25.0, 90.0, 102.0] | [536, 539, 558] |
p02683 | u311113280 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import sys\nN,M,X=map(int,input().split())\nL=[list(map(int,input().split())) for i in range(N)]\n#print(L)\nprice=[]\nlist_X=[X for i in range(M)]\nprint(list_X)\nfor i in range(2**N):\n A=[0 for i in range(M+1)]\n for j in range(N):\n if (i>>j) & 1:\n A = [x+y for (x,y) in zip(A,L[j])] \n #print(A)\n large = 0\n for i in range(M):\n if A[i+1] >= list_X[i]:\n large += 1\n if large == M:\n price.append(A[0])\n #if A[1:] >= list_X:\n #price.append(A[0])\n#print(price)\nif price ==[]:\n print(-1)\nelse:\n print(min(price))', 'import sys\nN,M,X=map(int,input().split())\nL=[list(map(int,input().split())) for i in range(N)]\n#print(L)\nprice=[]\nlist_X=[X for i in range(M)]\n#print(list_X)\nfor i in range(2**N):\n A=[0 for i in range(M+1)]\n for j in range(N):\n if (i>>j) & 1:\n A = [x+y for (x,y) in zip(A,L[j])] \n #print(A)\n large = 0\n for i in range(M):\n if A[i+1] >= list_X[i]:\n large += 1\n if large == M:\n price.append(A[0])\n #if A[1:] >= list_X:\n #price.append(A[0])\n#print(price)\nif price ==[]:\n print(-1)\nelse:\n print(min(price))'] | ['Wrong Answer', 'Accepted'] | ['s882986548', 's672918508'] | [9172.0, 9136.0] | [62.0, 64.0] | [532, 533] |
p02683 | u314089899 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['A,B,C,K = map(int, input().split())\nif K<=A:\n print(K)\nelif A<=K<=A+B:\n print(A)\nelse:\n print(A-(K-A-B))\n \n \n \n \nN,M,X = map(int, input().split())\nCA_array = list()\nfor i in range(N):\n CA_list = [int(e) for e in input().split()]\n CA_array.append(CA_list)\n \nans = 13*(10**5)\n \n\nfor i in range(2**(N)): #4096\n bit_array = str(bin(i)[2:]).zfill((N))\n #print(bit_array)\n\n CA_on_bit_array = [0 for _ in range(M+1)]\n \n for j in range(len(bit_array)): #12\n\n if bit_array[j]=="0":\n \n pass\n elif bit_array[j]=="1":\n \n for k in range(M+1): #13\n CA_on_bit_array[k] += CA_array[j][k]\n\n \n for k in range(1,M+1):\n if CA_on_bit_array[k] < X:\n break\n else:\n if CA_on_bit_array[0] < ans:\n ans = CA_on_bit_array[0]\n\nif ans != 13*(10**5):\n print(ans)\nelse:\n print(-1)', 'N,M,X = map(int, input().split())\nCA_array = list()\nfor i in range(N):\n CA_list = [int(e) for e in input().split()]\n CA_array.append(CA_list)\n \nans = 13*(10**5)\n \n\nfor i in range(2**(N)): #4096\n bit_array = str(bin(i)[2:]).zfill((N))\n #print(bit_array)\n\n CA_on_bit_array = [0 for _ in range(M+1)]\n \n for j in range(len(bit_array)): #12\n\n if bit_array[j]=="0":\n \n pass\n elif bit_array[j]=="1":\n \n for k in range(M+1): #13\n CA_on_bit_array[k] += CA_array[j][k]\n\n \n for k in range(1,M+1):\n if CA_on_bit_array[k] < X:\n break\n else:\n if CA_on_bit_array[0] < ans:\n ans = CA_on_bit_array[0]\n\nif ans != 13*(10**5):\n print(ans)\nelse:\n print(-1)'] | ['Runtime Error', 'Accepted'] | ['s854563058', 's737597285'] | [9176.0, 9216.0] | [24.0, 98.0] | [1043, 909] |
p02683 | u317779196 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nimport itertools\nn,m,x = map(int, input().split())\nca = np.zeros((n,m+1))\nfor i in range(n):\n ca[i] = [int(i) for i in input().split()]\n\n\np = itertools.product([True,False], repeat = n)\nans = []\nfor i in p:\n ca_cut = ca[i,:]\n if len(ca_cut) == 0: \n continue\n ca_cut_sum = ca_cut.sum(axis=0)\n if all(ca_cut_sum[1:] >= x):\n ans.append(ca_cut_sum[0])\nif len(ans) == 0:\n ans = -1\nelse:\n ans = min(ans)\nprint(ans)', 'import numpy as np\nimport itertools\nn,m,x = map(int, input().split())\nca = np.zeros((n,m+1))\nfor i in range(n):\n ca[i] = [int(i) for i in input().split()]\n\np = itertools.product([True,False], repeat = n)\nans_l = []\nfor i in p:\n ca_cut = ca[i,:]\n if len(ca_cut) == 0: \n continue\n ca_cut_sum = ca_cut.sum(axis=0)\n if all(ca_cut_sum[1:] >= x):\n ans_l.append(ca_cut_sum[0])\nif len(ans_l) == 0:\n ans = -1\nelse:\n ans = min(ans_l)\nprint(ans)', 'import numpy as np\nimport itertools\nn,m,x = map(int, input().split())\nca = np.zeros((n,m+1))\nfor i in range(n):\n ca[i] = [int(i) for i in input().split()]\n\n\np = itertools.product([True,False], repeat = n)\nans = []\nfor i in p:\n ca_cut = ca[i,:]\n ca_cut_sum = ca_cut.sum(axis=0)\n if all(ca_cut_sum[1:] >= x):\n ans.append(ca_cut_sum[0])\nif len(ans) == 0:\n ans = -1\nelse:\n ans = min(ans)\nprint(ans)', 'import numpy as np\nimport itertools\nn,m,x = map(int, input().split())\nca = np.zeros((n,m+1))\nfor i in range(n):\n ca[i] = [int(i) for i in input().split()]\n\n\n\np = itertools.product([True,False], repeat = n)\nans_l = []\nfor i in p:\n ca_cut = ca[i,:]\n if len(ca_cut) == 0: \n continue\n ca_cut_sum = ca_cut.sum(axis=0)\n if all(ca_cut_sum[1:] >= x):\n ans_l.append(ca_cut_sum[0])\nif len(ans_l) == 0:\n ans = -1\nelse:\n ans = min(ans_l)\nprint(int(ans))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s034023898', 's245618675', 's420307907', 's655897826'] | [27252.0, 27176.0, 27332.0, 27280.0] | [156.0, 154.0, 153.0, 150.0] | [656, 469, 613, 725] |
p02683 | u321096814 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["# coding: utf-8\n# Your code here!\nimport itertools\nimport sys\nN, M, X = map(int, input().split())\nmoney = []\nA = []\nans = 0\nfor _ in range(N):\n nums = [int(x.strip()) for x in input().split(' ') ]\n money.append(nums[0])\n nums.pop(0)\n A.append(nums)\n \ndef run(lis, num, A, X, M):\n tmp_ans = sum(lis)\n for team in itertools.combinations(lis, num):\n count = 0\n for i in range(M):\n tmp = 0\n for j in list(team):\n tmp += A[lis.index(j)][i]\n if tmp >= X:\n count += 1\n if sum(list(team)) < tmp_ans and count == num:\n tmp_ans = sum(list(team))\n if not tmp_ans == sum(lis):\n print(tmp_ans)\n sys.exit()\nfor i in range(2, N+1):\n run(money, i, A, X, M)\n\nprint(-1)", "# coding: utf-8\n# Your code here!\nimport itertools\nimport sys\nimport copy\nN, M, X = map(int, input().split())\nmoney = []\nA = []\nans = 0\nfor _ in range(N):\n nums = [int(x.strip()) for x in input().split(' ') ]\n money.append(nums[0])\n nums.pop(0)\n A.append(nums)\n \ndef run(lis, num, A, X, M):\n ans_list = []\n for team in itertools.combinations(lis, num):\n count = 0\n for i in range(M):\n tmp = 0\n for j in list(team):\n tmp += A[lis.index(j)][i]\n if tmp >= X:\n count += 1\n if count == M:\n ans_list.append(sum(list(team)))\n if not len(ans_list) == 0:\n print(min(ans_list))\n sys.exit()\nfor i in range(1, N+1):\n run(money, i, A, X, M)\n print(i)\n\nprint(-1)", "# coding: utf-8\n# Your code here!\nimport itertools\nimport sys\n\nN, M, X = map(int, input().split())\nmoney = []\nA = []\nans = []\nfor _ in range(N):\n nums = [int(x.strip()) for x in input().split(' ') ]\n money.append(nums[0])\n nums.pop(0)\n A.append(nums)\nnum_money = []\nfor index, num in enumerate(money):\n num_money.append(index)\n \ndef run(lis, num, A, X, M, ans, money):\n ans_list = []\n for team in itertools.combinations(lis, num):\n count = 0\n for i in range(M):\n tmp = 0\n for j in list(team):\n tmp += A[j][i]\n if tmp >= X:\n count += 1\n if count == M:\n tmp_ans = []\n for n in list(team):\n tmp_ans.append(money[n])\n ans_list.append(sum(tmp_ans))\n if not len(ans_list) == 0:\n ans.append(min(ans_list))\n \n return ans\n \nfor i in range(1, N+1):\n ans = run(num_money, i, A, X, M, ans, money)\n \nif not len(ans) == 0:\n print(min(ans))\n \nelse:\n print(-1)"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s593560153', 's972395362', 's648335085'] | [9252.0, 9368.0, 9304.0] | [74.0, 77.0, 49.0] | [788, 788, 1039] |
p02683 | u329675280 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\n\n_,*_t=[list(map(int,i.split())) for i in open(0)]\nn=_[0]\nm=_[1]\nx=_[2]\ntable=np.array(_t)\nvalue=9000000\n\n\ndef boolAchieve(nums):\n for i in range(1,m+1):\n if nums[i]<x:\n return False\n return True\n\n\ntmp=np.sum(table,axis=0)\nif not boolAchieve(tmp):\n print(-1)\n exit()\n\n\nfor i in range(1,2 ** n):\n selects=[bool(i >> j) for j in range(n)]\n picks=np.sum(table[selects,:],axis=0)\n if not boolAchieve(picks):\n continue\n value=min(value,picks[0])\n\n \nprint(value)', 'import itertools\nimport numpy as np\n\n_,*_t=[list(map(int,i.split())) for i in open(0)]\nn=_[0]\nm=_[1]\nx=_[2]\ntable=np.array(_t)\npatterns=list(itertools.product([False,True], repeat=n))\nvalue=9000000\n\n\ndef boolAchieve(nums):\n for i in range(1,m+1):\n if nums[i]<x:\n return False\n return True\n\n\ntmp=np.sum(table,axis=0)\nif not boolAchieve(tmp):\n print(-1)\n exit()\n\n\nfor i in range(1,2 ** n):\n selects=patterns[i]\n picks=np.sum(table[selects,:],axis=0)\n if not boolAchieve(picks):\n continue\n value=min(value,picks[0])\n\n \nprint(value)'] | ['Wrong Answer', 'Accepted'] | ['s501912606', 's980917051'] | [27356.0, 27672.0] | [154.0, 152.0] | [495, 548] |
p02683 | u336968242 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["nmx=list(map(int, input().split()))\nN=nmx[0]\nM=nmx[1]\nX=nmx[2]\nlist=[input().split() for i in range(N)]\nalist=[0]*M\nfor i in range(N):\n c=int(list[i][0])\n for j in range(1,M+1):\n a=int(list[i][j])\n alist[j-1]+=a\nif min(alist)<X:\n print('-1')\nelse:\n for i in range(N):\n c=int(list[i][0])\n for j in range(1,M+1):\n a=int(list[i][j])\n", "nmx=list(map(int, input().split()))\nN=nmx[0]\nM=nmx[1]\nX=nmx[2]\nlist=[input().split() for i in range(N)]\nflg=False\nalist=[[0]*M]*2**N \nclist=[0]*2**N \nfor k in range(2**N):\n for i in range(N):\n if (k>>i) & 1:\n c=int(list[i][0])\n clist[k]+=c\n for j in range(M):\n a=int(list[i][j+1])\n alist[k][j]+=a\n if min(alist[k])<X:\n clist[k]=12*10**5\n else:\n flg=True\nif flg:\n clist.sort()\n print(clist[0])\nelse:\n print('-1')\n", "nmx=list(map(int, input().split()))\nN=nmx[0]\nM=nmx[1]\nX=nmx[2]\nls=[input().split() for i in range(N)]\nflg=False\nalist=[[0 for p in range(M)] for q in range(2**N)]\nclist=[0]*2**N \nfor k in range(2**N):\n for i in range(N):\n if (k>>i) & 1:\n c=int(ls[i][0])\n clist[k]+=c\n for j in range(M):\n a=int(ls[i][j+1])\n alist[k][j]+=a\n if min(alist[k])<X:\n clist[k]=12*10**5+1\n else:\n flg=True\nif flg:\n clist.sort()\n print(clist[0])\nelse:\n print('-1')\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s280609625', 's432263449', 's978679814'] | [9224.0, 9280.0, 11208.0] | [24.0, 138.0, 141.0] | [381, 603, 630] |
p02683 | u338083088 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nimport copy\nN, M, X = map(int, input().split())\nC = np.zeros(N, dtype=np.uint16)\nA = np.zeros([N, M], dtype=np.unt16)\nskills = np.zeros(M, dtype=np.uint16)\nsum_skills = np.zeros(M, dtype=np.uint32)\nsum_A = np.zeros(N, dtype=np.uint32)\n\nfor n in range(N):\n CA = list(map(int, input().split()))\n C[n] = CA[0]\n A[n] = CA[1:]\n sum_skills += CA[1:]\n sum_A[n] = sum(CA[1:])\n\n\ndef check_skills(skills):\n return np.all(skills >= X)\n\n\nif np.all(sum_skills >= X):\n pass\nelse:\n print("-1")\n exit()\n\nresults = []\nbook_sorted = np.argsort(sum_A)\nfor n in range(M):\n result = ([n], C[n].copy(), A[n].copy())\n results.append(result)\n\nmin_cost = np.sum(C)\n\nwhile len(results) > 0:\n result = results.pop(0)\n if check_skills(result[2]):\n min_cost = min(min_cost, result[1])\n elif result[1] > min_cost:\n continue\n else:\n max_idx = max(result[0])\n for idx in range(max_idx+1, N):\n (idxes, total_cost, skill_values) = copy.copy(result)\n idxes = idxes + [idx]\n total_cost = total_cost + C[idx]\n skill_values = skill_values + A[idx]\n results.append((idxes, total_cost, skill_values))\n\nprint(min_cost)\n', 'N, M, X = map(int, input().split())\n\nA = [[] for i in range(N)]\nC = [0] * N\nfor i in range(N):\n c_as = list(map(int, input().split()))\n C[i], A[i] = c_as[0], c_as[1:]\n\nINF = 10**9\nans = INF\nfor s in range(0, 1 << N):\n smart = [0] * M\n cost_sum = 0\n for i in range(N):\n if (s >> i) % 2 == 0:\n continue\n cost_sum += C[i]\n for j in range(M):\n smart[j] += A[i][j]\n ok = True\n for j in range(M):\n if smart[j] < X:\n ok = False\n if ok:\n ans = min(ans, cost_sum)\nif ans == INF:\n ans = -1\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s581086616', 's615874953'] | [27184.0, 9244.0] | [106.0, 84.0] | [1225, 586] |
p02683 | u340040203 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["import sys\nimport numpy as np\nn, m, x = list(map(int, input().split()))\nc = []\na = []\nprice = 0\nm_achive = [0 for _ in range(m)]\nfor i in sys.stdin:\n temp = list(map(int, i.split()))\n c.append(temp[0])\n a.append(list(temp[1:])) \n\narray = np.array(a).transpose()\n\nif(sum(array[0])>x):\n sorted(array[0], reverse=True)\nelse:\n print('-1')", "n, m, x = map(int, input().split())\nbooks = [list(map(int, input().split())) for _ in range(n)]\nmoney = []\n\nfor i in range(2 ** n):\n value = [0] * (m+1)\n for j in range(n):\n if (i >> j) & 1:\n value = [value[k]+books[j][k] for k in range(m+1)]\n \n for l in range(m):\n if value[l+1] < x:\n break\n elif l == m-1:\n money.append(value[0])\n \nif len(money) == 0:\n print('-1')\nelse:\n print(min(money))"] | ['Wrong Answer', 'Accepted'] | ['s522960125', 's889102254'] | [27220.0, 9220.0] | [105.0, 76.0] | [339, 482] |
p02683 | u343850880 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x = list(map(int,input().split()))\nb = []\nimport numpy as np\nfor i in range(n):\n ca = list(map(int,input().split()))\n b.append(ca)\nb = np.array(b)\nans = 10**5*12\nfor i in range(1<<n):\n num = np.array([0 for j in range(m+1)])\n for k in range(n):\n if (i>>k&1)==1:\n num += b[k]\n print(num)\n if (num[1:]>=x).sum()==m:\n ans = min(ans, num[0])\n print(ans)\nprint(ans if ans!=10**5*12 else -1)', "n,m,x = list(map(int,input().split()))\nb = []\nimport numpy as np\nfor i in range(n):\n ca = list(map(int,input().split()))\n b.append(ca)\nb = np.array(b)\nans = float('inf')\nfor i in range(1<<n):\n num = np.array([0 for j in range(m+1)])\n for k in range(n):\n if (i>>k&1)==1:\n num += b[k]\n if (num[1:]>=x).sum()==m:\n ans = min(ans, num[0])\nprint(ans if ans!=float('inf') else -1)"] | ['Wrong Answer', 'Accepted'] | ['s220389165', 's989809538'] | [26680.0, 27164.0] | [1223.0, 236.0] | [443, 413] |
p02683 | u347640436 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["from itertools import product\n\nN, M, X = map(int, input().split())\n\nC = []\nA = []\nfor i in range(N):\n t = list(map(int, input().split()))\n C.append(t[0])\n A.append(t[1:])\n\nresult = float('inf')\nfor p in product([True, False], N):\n t = [0] * M\n c = 0\n for j in range(N):\n if not p[j]:\n continue\n c += C[j]\n for k in range(M):\n t[k] += A[j][k]\n if all(x >= X for x in t):\n result = min(result, c)\nprint(result)\n", 'N, M, X = map(int, input().split())\n\nC = []\nA = []\nfor i in range(N):\n t = list(map(int, input().split()))\n C.append(t[0])\n A.append(t[1:])\n\nresult = -1\nfor i in range(1 << N):\n t = [0] * M\n c = 0\n for j in range(N):\n if (i >> j) & 1 == 0:\n continue\n c += C[j]\n for k in range(M):\n t[k] += A[j][k]\n if all(x >= X for x in t):\n if result == -1:\n result = c\n else:\n result = min(result, c)\nprint(result)\n'] | ['Runtime Error', 'Accepted'] | ['s944278939', 's481595753'] | [9104.0, 9068.0] | [24.0, 84.0] | [480, 502] |
p02683 | u357949405 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['print(-1)', 'N, M, X = map(int, input().split())\nA = []\nC = []\nfor _ in range(N):\n CA = list(map(int, input().split()))\n C.append(CA[0])\n A.append(CA[1::])\n\n# print(A)\n# print(C)\n\nans_money = float(\'inf\')\n# ans_algorythm = None\nfor i in range(2**(N-1)):\n bit = bin(i)[2::]\n # print("bit: {}".format(bit))\n tmp_money = 0\n tmp_algorythm = [0] * M\n for j, b in enumerate(bit[::-1]):\n if b == \'1\':\n tmp_money += C[j]\n for k, c in enumerate(A[j]):\n tmp_algorythm[k] += c\n \n if len(list(filter(lambda x: x < X, tmp_algorythm))) == 0:\n ans_money = min(tmp_money, ans_money)\n break\n\nif ans_money == float(\'inf\'):\n print(-1)\nelse:\n print(ans_money)\n', 'DEBUG = True\n\nimport time\n\nN, K = map(int, input().split())\nA = [int(i)-1 for i in input().split()]\n\nvisited = [False] * N\nnext = A[0]\nvisited[0] = True\nK -= 1\nwhile not visited[next]:\n if DEBUG:\n print("K: {}, next: {}".format(K, next))\n print("visited: {}".format(visited))\n time.sleep(0.1)\n if K == 0:\n print(next+1)\n exit()\n visited[next] = True\n next = A[next]\n K -= 1\n\nK -= 1\nnow = next\ncount = 1\nnext = A[next]\nwhile now != next:\n next = A[next]\n count += 1\nif DEBUG:\n print("count: {}".format(count))\n\nK %= count\n\nif DEBUG:\n print("now: {}, count: {}, K: {}".format(now, count, K))\n\nwhile K > 0:\n if DEBUG:\n print("now: {}".format(now))\n now = A[now]\n K -= 1\n\nprint(A[now]+1)\n', 'DEBUG = False\n\nN, M, X = map(int, input().split())\nA = []\nC = []\nfor _ in range(N):\n CA = list(map(int, input().split()))\n C.append(CA[0])\n A.append(CA[1::])\n\nif DEBUG:\n print(A)\n print(C)\n\nmax_money = 10**5 * N + 1\nans_money = max_money\n# ans_algorythm = None\nfor i in range(2**N):\n bit = bin(i)[2::]\n bit = bit.zfill(N)\n if DEBUG:\n print("i: {}, bit: {}".format(i, bit))\n tmp_money = 0\n tmp_algorythm = [0] * M\n for j, b in enumerate(bit):\n if b == \'1\':\n tmp_money += C[j]\n for k, c in enumerate(A[j]):\n tmp_algorythm[k] += c\n if DEBUG:\n print("tmp_money: {}, tmp_algorythm: {}".format(tmp_money, tmp_algorythm))\n if len(list(filter(lambda x: x < X, tmp_algorythm))) == 0:\n ans_money = min(tmp_money, ans_money)\n if DEBUG:\n print("ans_money: {}".format(ans_money))\n # break\n\nif ans_money == max_money:\n print(-1)\nelse:\n print(ans_money)\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s373717575', 's466999955', 's501791229', 's111253054'] | [9092.0, 9232.0, 9140.0, 9272.0] | [23.0, 46.0, 24.0, 72.0] | [9, 797, 762, 974] |
p02683 | u360061665 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["import sys\nimport itertools\nimport numpy as np\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN, M, X = map(int, input().split(' '))\nC = []\nA = []\nfor i in range(N):\n c, *a = map(int, input().split(' '))\n C.append(c)\n A.append(np.array(a))\n\nans = np.inf\n\nfor i in range(2**N):\n point = np.zeros(M)\n cost = 0\n\n for j in range(N):\n if ((i >> j) & 1):\n point += A[j]\n cost += C[j]\n\n if np.all(point >= X):\n print(point)\n ans = min(ans, cost)\n\nif ans != np.inf:\n print(ans)\nelse:\n print('-1')\n", "import sys\nimport itertools\nimport numpy as np\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN, M, X = map(int, input().split(' '))\nC = []\nA = []\nfor i in range(N):\n c, *a = map(int, input().split(' '))\n C.append(c)\n A.append(np.array(a))\n\nans = np.inf\n\nfor i in range(2**N):\n point = np.zeros(M)\n cost = 0\n\n for j in range(N):\n if ((i >> j) & 1):\n point += A[j]\n cost += C[j]\n\n if np.all(point >= X):\n ans = min(ans, cost)\n\nif ans != np.inf:\n print(ans)\nelse:\n print('-1')\n"] | ['Wrong Answer', 'Accepted'] | ['s144225474', 's285676759'] | [27364.0, 27236.0] | [658.0, 167.0] | [619, 598] |
p02683 | u363825867 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\n\nN, M, X = [int(i) for i in input().split()]\nCA = [] # (C, A)\nA = []\nfor i in range(N):\n c, *a = [int(i) for i in input().split()]\n CA.append((c, a))\n\nmin_c = 12 * 10**5 + 1\nfor x in range(1, N+1):\n for ca in itertools.combinations(CA, x):\n tmp_a = [0 for _ in range(M)]\n tmp_c = 0\n for s in ca:\n tmp_c += s[0]\n tmp_a = [tmp_a[j]+s[1][j] for j in range(M)]\n print(tmp_a)\n if min(tmp_a) >= X:\n min_c = min(min_c, tmp_c)\n\nif min_c == 12 * 10**5 + 1:\n print(-1)\nelse:\n print(min_c)\n', 'import itertools\n\nN, M, X = [int(i) for i in input().split()]\nCA = [] # (C, A)\nA = []\nfor i in range(N):\n c, *a = [int(i) for i in input().split()]\n CA.append((c, a))\n\nmin_c = 12 * 10**5 + 1\nfor x in range(1, N+1):\n for ca in itertools.combinations(CA, x):\n tmp_a = [0 for _ in range(M)]\n tmp_c = 0\n for s in ca:\n tmp_c += s[0]\n tmp_a = [tmp_a[j]+s[1][j] for j in range(M)]\n if min(tmp_a) >= X:\n min_c = min(min_c, tmp_c)\n\nif min_c == 12 * 10**5 + 1:\n print(-1)\nelse:\n print(min_c)\n'] | ['Wrong Answer', 'Accepted'] | ['s364196732', 's998351182'] | [9244.0, 9216.0] | [70.0, 60.0] | [579, 558] |
p02683 | u364027015 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nN=int(input())\nA=np.zeros(N+1)\na=list(map(int,input().split()))\nfor i in range(N+1):\n A[i]=a[i]\nv=0\nj=0\nk=0\nB=np.zeros(N+1)\nfor i in range(N+1):\n B[i]=N-i\nfor i in reversed(range(0, N+1)):\n j+=A[i]/(2**i)\n if i==N:\n k=A[i]\n else:\n k=min(k+A[i],2**i-np.sum(A[0:i]*(2**(B[0:i]-(N-i)))))\n v+=k\n\nif j>1:\n print(-1)\nelse:\n print(int(v))', 'import numpy as np\nN,M,X=map(int,input().split())\nC=np.zeros(N,dtype=int)\nA=np.zeros([N,M],dtype=int)\nfor i in range(N):\n T=list(map(int,input().split()))\n C[i]=T[0]\n for j in range(M):\n A[i,j]=T[j+1]\na=np.zeros(N,dtype=int)\nans=-1\nwhile a.all()!=1:\n if ((a@A)>=X).all():\n if ans==-1:\n ans=a@(C.T)\n elif a@(C.T)<ans:\n ans=a@(C.T)\n for i in range(N):\n if a[N-i-1]==0:\n a[N-i-1]=1\n break\n else:\n a[N-i-1]=0\n\nif ((a@A)>=X).all():\n if ans==-1:\n ans=a@(C.T)\n elif a@(C.T)<ans:\n ans=a@(C.T)\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s163801367', 's775087696'] | [27148.0, 27324.0] | [112.0, 144.0] | [364, 567] |
p02683 | u364099990 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['line = input()\nN, M, X = [int(v) for v in line.split(" ")]\n\nCi, Aij = [], []\nfor i in range(N):\n line = input().split(" ")\n line = [int(v) for v in line]\n\n Ci.append(line[0])\n Aij.append(line[1:])\n\n\nans = []\ndef dfs(candidate):\n if len(candidate) == M:\n X_ = [0 for _ in range(M)]\n cost = 0\n for i in range(N):\n for j in range(M):\n X_[j] += Aij[i][j] * candidate[i]\n cost += Ci[i] * candidate[i]\n if min(X_) >= X:\n ans.append(cost)\n return\n\n for bit in range(0):\n dfs(candidate + [bit])\n\n\n\nif len(ans) == 0:\n print(-1)\nelse:\n print(min(ans))', 'line = input()\nN, M, X = [int(v) for v in line.split(" ")]\n\nCi, Aij = [], []\nfor i in range(N):\n line = input().split(" ")\n line = [int(v) for v in line]\n\n Ci.append(line[0])\n Aij.append(line[1:])\n\nans = []\ndef dfs(candidate):\n if len(candidate) == N:\n X_ = [0 for _ in range(M)]\n cost = 0\n for i in range(N):\n if candidate[i] == 0:\n continue\n cost += Ci[i]\n for j in range(M):\n X_[j] += Aij[i][j]\n if min(X_) >= X:\n ans.append(cost)\n else:\n for bit in range(2):\n candidate.append(bit)\n dfs(candidate)\n candidate.pop()\n\ndfs([])\nif len(ans) == 0:\n print(-1)\nelse:\n print(min(ans))'] | ['Wrong Answer', 'Accepted'] | ['s545016683', 's207070294'] | [9228.0, 9340.0] | [21.0, 63.0] | [659, 745] |
p02683 | u364693468 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import bisect\nN, M, X = map(int, input().split())\nC = [0] * N\nA = [0] * N\nfor i in range(N):\n x = list(map(int, input().split()))\n C[i] = x[0]\n A[i] = [0] * M\n for j in range(M):\n A[i][j] = x[j + 1]\ncnt = [0] * (2 **N)\nans_list = []\nfor i in range(2 ** N):\n bag = []\n cnt[i] = [0] * M\n for j in range(N): \n if ((i >> j) & 1): \n bag.append(C[j]) \n for k in range(M):\n cnt[i][k] += A[j][k]\n if bisect.bisect_left(cnt[i], X) == 0:\n ans_list.append(sum(bag))\nif ans_list == []:\n print(-1)\nelse:\n print(min(ans_list)', 'import bisect\nN, M, X = map(int, input().split())\nC = [0] * N\nA = [0] * N\nfor i in range(N):\n x = list(map(int, input().split()))\n C[i] = x[0]\n A[i] = [0] * M\n for j in range(M):\n A[i][j] = x[j + 1]\ncnt = [0] * (2 ** N)\nans_list = []\nfor i in range(2 ** N):\n bag = []\n cnt[i] = [0] * M\n for j in range(N):\n if ((i >> j) & 1):\n bag.append(C[j])\n for k in range(M):\n cnt[i][k] += A[j][k]\n cnt[i].sort()\n if bisect.bisect_left(cnt[i], X) == 0:\n ans_list.append(sum(bag))\nif ans_list == []:\n print(-1)\nelse:\n print(min(ans_list))'] | ['Runtime Error', 'Accepted'] | ['s282373705', 's081113015'] | [9028.0, 11276.0] | [25.0, 95.0] | [766, 616] |
p02683 | u371763408 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['CA = [list(map(int,input().split())) for _ in range(n)]\n\nans = 10**9\n\nfor i in range(2**n):\n ls = [0] * m\n tmp = 0\n for j in range(n):\n if (i >> j) & 1:\n ls = [l + a for l, a in zip(ls, CA[j][1:])]\n tmp += CA[j][0]\n if all(i >= x for i in ls):\n ans = min(ans, tmp)\nprint(ans if ans != 10**9 else -1)', 'n, m, x = map(int,input().split())\nCA = [list(map(int,input().split())) for _ in range(n)]\n\nans = 10**9\n\nfor i in range(2**n):\n ls = [0] * m\n tmp = 0\n for j in range(n):\n if (i >> j) & 1:\n ls = [l + a for l, a in zip(ls, CA[j][1:])]\n tmp += CA[j][0]\n if all(i >= x for i in ls):\n ans = min(ans, tmp)\nprint(ans if ans != 10**9 else -1)'] | ['Runtime Error', 'Accepted'] | ['s481566414', 's679291932'] | [9148.0, 9224.0] | [24.0, 60.0] | [347, 382] |
p02683 | u374501720 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["import itertools\nimport numpy as np\n\nn, m, x = map(int, input().split())\n\nnum = [i for i in range(n)]\n\nbook_list = []\nfor i in range(n):\n book_list.append(list(map(int, input().split())))\n\n\nfor k in range(1, n+1):\n correct = []\n\n for v in itertools.combinations(num, k):\n test = [] \n for j in v:\n test.append(book_list[j])\n sum_test = np.sum(test, axis = 0) \n cnt = 0\n for i in range(1, m+1):\n if sum_test[i] >= x:\n cnt += 1\n if cnt == m:\n correct.append(sum_test[0]) \n \nif sum(correct) > 0:\n print(min(correct))\n \nelse:\n print('-1')\n", "import itertools\nimport numpy as np\n\nn, m, x = map(int, input().split())\n\nnum = [i for i in range(n)]\n\nbook_list = []\nfor i in range(n):\n book_list.append(list(map(int, input().split())))\n\n\ncorrect = []\nfor k in range(1, n+1):\n\n for v in itertools.combinations(num, k):\n test = [] \n for j in v:\n test.append(book_list[j])\n sum_test = np.sum(test, axis = 0) \n cnt = 0\n for i in range(1, m+1):\n if sum_test[i] >= x:\n cnt += 1\n if cnt == m:\n correct.append(sum_test[0]) \n \nif sum(correct) > 0:\n print(min(correct))\n \nelse:\n print('-1')\n"] | ['Wrong Answer', 'Accepted'] | ['s636387264', 's802696856'] | [27404.0, 27676.0] | [443.0, 432.0] | [672, 670] |
p02683 | u377834804 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['N, M, X = map(int, input().split())\nbook = [[map(int, input().split())] for i in range(N)]\n\nmin_value = -1\nfor i in range(2**N):\n sum = [0 for k in range(M+1)]\n for j in range(N):\n if (i >> j) & 1:\n sum = [x+y for x, y in zip(sum, book[N+1])]\n if min(sum[1:]) >= X and min_value > sum[0]:\n min_value = sum[0]\n\nprint(min_value)', 'N, M, X = map(int, input().split())\nbook = [list(map(int, input().split())) for i in range(N)]\n\nmin_value = -1\nfor i in range(2**N):\n sum = [0 for k in range(M+1)]\n for j in range(N):\n if (i >> j) & 1:\n sum = [x+y for x, y in zip(sum, book[j])]\n if min(sum[1:]) >= X and (min_value > sum[0] or min_value == -1):\n min_value = sum[0]\n\nprint(min_value)\n'] | ['Runtime Error', 'Accepted'] | ['s256801134', 's427489170'] | [9164.0, 9208.0] | [25.0, 58.0] | [340, 384] |
p02683 | u379716238 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\n\nN, M, X = map(int, input().split())\nca = []\nfor _ in range(N):\n ca.append(list(map(int, input().split())))\n \nns = [i for i in range(N)]\nprice = 1000000000000\nfor r in range(1,N+1):\n for v in itertools.combinations(ns, r):\n flag = True\n for j in range(M):\n s = sum([ca[i][j+1] for i in v])\n print(v, s)\n if s < X:\n flag = False\n continue\n if flag:\n p = sum([ca[i][0] for i in v])\n price = min(price, p)\n \nif price == 1000000000000:\n print(-1)\nelse:\n print(price)', 'import itertools\n\nN, M, X = map(int, input().split())\nca = []\nfor _ in range(N):\n ca.append(list(map(int, input().split())))\n \nns = [i for i in range(N)]\nprice = 1000000000000\nfor r in range(1,N+1):\n for v in itertools.combinations(ns, r):\n flag = True\n for j in range(M):\n s = sum([ca[i][j+1] for i in v])\n if s < X:\n flag = False\n continue\n if flag:\n p = sum([ca[i][0] for i in v])\n price = min(price, p)\n \nif price == 1000000000000:\n print(-1)\nelse:\n print(price)'] | ['Wrong Answer', 'Accepted'] | ['s490178344', 's617322797'] | [9316.0, 9228.0] | [112.0, 58.0] | [537, 519] |
p02683 | u382407432 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy\nN,M,X=map(int,(input().split()))\nbook=[]\nfor i in range(N):\n book.append(list(map(int,(input().split()))))\nrow_sum = numpy.sum(book, axis=0)\nif(min(row_sum<X)):\n print("-1")', 'import numpy\nN,M,X=map(int,(input().split()))\nbook=[]\nfor i in range(N):\n book.append(list(map(int,(input().split()))))\nrow_sum = numpy.sum(book, axis=0)\nif(min(row_sum)<X):\n print("-1")', 'import numpy\nimport sys\n\nN,M,X=map(int,(input().split()))\nbook=[list(map(int,input().split())) for _ in range(N)]\n\nrow_sum = numpy.sum(book, axis=0)\nif(min(row_sum)<X):\n print("-1")\n sys.exit()\n\nresult=-1\nfor i in range(2**N):\n t=[0]*M\n money=0\n for j in range(N):\n \n if (i>>j)&1==0:\n continue\n money+=book[j][0]\n for k in range(1,M+1):\n t[k-1]+=book[j][k]\n \n if all(xx>=X for xx in t):\n if(result==-1):\n result=money\n else:\n result=min(result,money)\nprint(result)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s644745740', 's802797435', 's100938866'] | [27360.0, 27276.0, 27240.0] | [109.0, 102.0, 168.0] | [188, 188, 628] |
p02683 | u382639013 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nn, M, X = list(map(int, input().split()))\nCA = []\nA = []\nfor _ in range(N):\n L = list(map(int, input().split()))\n CA.append(L[:])\nans = np.zeros(M+1)\n\nS = [0]*n\nANS = list()\ndef makeCombination():\n for i in range(0, n-1):\n S[i] = 0\n rec(0, ans)\ndef rec(i,ans):\n if i == n:\n if all(ans[1:] >= X) == True:\n ANS.append(ans[0])\n return\n rec(i + 1,ans)\n S[i] = 1\n ans = ans + np.array(CA[i])\n rec(i + 1, ans)\n S[i] = 0\nmakeCombination()\nANS.sort()\nif len(ANS) >= 1:\n print(ANS[0])\nelse:\n print(-1)', 'import numpy as np\nn, M, X = list(map(int, input().split()))\nCA = []\nA = []\nfor _ in range(N):\n L = list(map(int, input().split()))\n CA.append(L[:])\nans = np.zeros(M+1)\nS = [0]*n\nANS = list()\ndef makeCombination():\n for i in range(0, n-1):\n S[i] = 0\n rec(0, ans)\ndef rec(i,ans):\n if i == n:\n #print(S)\n print(ans)\n print(ans[1:] >= X)\n if all(ans[1:] >= X) == True:\n ANS.append(ans[0])\n return\n rec(i + 1,ans)\n S[i] = 1\n ans = ans + np.array(CA[i])\n rec(i + 1, ans)\n S[i] = 0\nmakeCombination()\nANS.sort()\nif len(ANS) >= 1:\n print(ANS[0])\nelse:\n print(-1)', 'import numpy as np\nn, M, X = list(map(int, input().split()))\nCA = []\nA = []\nfor _ in range(n):\n L = list(map(int, input().split()))\n CA.append(L[:])\nans = np.zeros(M+1)\n \nS = [0]*n\nANS = list()\ndef makeCombination():\n for i in range(0, n-1):\n S[i] = 0\n rec(0, ans)\ndef rec(i,ans):\n if i == n:\n if all(ans[1:] >= X) == True:\n ANS.append(ans[0])\n return\n rec(i + 1,ans)\n S[i] = 1\n ans = ans + np.array(CA[i])\n rec(i + 1, ans)\n S[i] = 0\nmakeCombination()\nANS.sort()\nif len(ANS) >= 1:\n print(ANS[0])\nelse:\n print(-1)', 'import numpy as np\nn, M, X = list(map(int, input().split()))\nCA = []\nA = []\nfor _ in range(n):\n L = list(map(int, input().split()))\n CA.append(L[:])\n \nans = np.zeros(M+1)\nS = [0]*n\nANS = list()\ndef makeCombination():\n for i in range(0, n-1):\n S[i] = 0\n rec(0, ans)\ndef rec(i,ans):\n if i == n:\n if all(ans[1:] >= X) == True:\n ANS.append(ans[0])\n return\n rec(i + 1,ans)\n S[i] = 1\n ans = ans + np.array(CA[i])\n rec(i + 1, ans)\n S[i] = 0\nmakeCombination()\nANS.sort()\nif len(ANS) >= 1:\n print(int(ANS[0]))\nelse:\n print(-1)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s014495804', 's083005884', 's662066450', 's616619955'] | [27120.0, 27140.0, 27244.0, 27244.0] | [117.0, 102.0, 118.0, 130.0] | [581, 645, 582, 591] |
p02683 | u387870994 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n, m, x = list(map(int, input().split()))\nc = []\na = []\n\nfor i in range(n):\n tmp = list(map(int, input().split()))\n c.append(tmp[0])\n a.append([])\n \n for j in range(m):\n a[i].append(tmp[j])\n\nab = []\nfor i in range(m):\n sum = 0\n for j in range(n):\n sum += a[j][i]\n ab.append(bool(sum > x))\n\nprint(300 if all(ab) else -1)', 'from itertools import combinations\n\nn, m, x = list(map(int, input().split()))\nc = []\na = []\n\n\nfor i in range(n):\n tmp = list(map(int, input().split()))\n c.append(tmp[0])\n a.append([])\n \n for j in range(m):\n a[i].append(tmp[j])\n\nmoney_min = -1\ncomb = []\n\nfor l in range(n):\n tmp = combinations(range(n), l + 1)\n for i in tmp:\n comb.append(i)\n \n\nfor el in comb:\n ables = []\n money = 0 \n scores = []\n\n \n for i in range(m):\n scores.append(0)\n\n \n for n in el:\n money += c[n] \n for i in range(m):\n scores[i] += a[n][i] \n\n \n for i in range(m):\n ables.append(scores[i] > x)\n\n \n if all(ables):\n money_min = money if money_min < 0 or money_min > money else money_min\n\nprint(money_min)', 'n, m, x = list(map(int, input().split()))\nc = []\na = []\n\nfor i in range(n):\n tmp = list(map(int, input().split()))\n c.append(tmp[0])\n a.append([])\n \n for j in range(m):\n a[i].append(tmp[j])\n\nab = []\nfor i in range(m):\n sum = 0\n for j in range(n):\n sum += a[j][i]\n ab.append(bool(sum > x))\n\nprint(all[ab])', 'from itertools import combinations\n\nn, m, x = list(map(int, input().split()))\nc = []\na = []\n\n\nfor i in range(n):\n tmp = list(map(int, input().split()))\n c.append(tmp[0])\n a.append([])\n \n for j in range(1, m + 1):\n a[i].append(tmp[j])\n\nmoney_min = -1\ncomb = []\n\nfor l in range(n):\n tmp = combinations(range(n), l + 1)\n for i in tmp:\n comb.append(i)\n \n\nfor el in comb:\n ables = []\n money = 0 \n scores = []\n\n \n for i in range(m):\n scores.append(0)\n\n \n for n in el:\n money += c[n] \n for i in range(m):\n scores[i] += a[n][i] \n\n \n for i in range(m):\n ables.append(scores[i] >= x)\n\n \n if all(ables):\n money_min = money if money_min < 0 or money_min > money else money_min\n\nprint(money_min)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s028311564', 's432376796', 's967005602', 's308291550'] | [9160.0, 9236.0, 9128.0, 9260.0] | [23.0, 87.0, 26.0, 88.0] | [357, 997, 342, 1005] |
p02683 | u406138190 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x=map(int,input().split())\narr=[[0 for i in range(m+1)] for j in range(n)]\nb=[0]*18\n\nflag=1\nfor i in range(n):\n arr[i]=list(map(int,input().split()))\nfor i in range(2**n):\n b=[0]*18\n for j in range(n):\n flag=1\n if (1& i>>j):\n for s in range(m+1):\n b[s]= b[s]+arr[j][s]\n for y in range(1,m+1):\n if(b[y]<x):\n flag=0\n \n if flag :\n if ans==-1 or ans>b[0]:\n ans=b[0]\nprint(ans)\n', 'n,m,x=map(int,input().split())\na=[[0]*(m+1)]*n\nfor i in range(n):\n a[i]=list(map(int,input().split()))\nb=[0]*(m+1)\nflag=True\nans=-1\nfor i in range(2**n):\n flag=True\n b=[0]*(m+1)\n for j in range(n):\n if(i>>j & 1):\n for y in range(m+1):\n b[y]=b[y]+a[j][y]\n for y in range(1,m+1):\n if(b[y]<x):\n flag=False\n break\n if(flag):\n if ans<0 or b[0]<ans:\n ans=b[0]\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s284935678', 's173763740'] | [9236.0, 9244.0] | [154.0, 98.0] | [507, 462] |
p02683 | u406379114 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n, m, x = map(int, input().split())\nc = []\na = [[] for _ in range(n)]\nfor i in range(n):\n inp = list(map(int, input().split()))\n c.append(inp[0])\n for j in range(m):\n a[i].append(inp[j+1])\nprint(c)\nprint(a)\nkumi=1\nfor i in range(n):\n kumi *= 2\nprint(kumi)\n \nmin_score = 10000000000000\nfor i in range(1, kumi):\n t = [0 for _ in range(m)]\n p = 0\n ni = format(i, \'b\').zfill(n)\n for j in range(n):\n if(ni[j]=="1"):\n for kk in range(m):\n t[kk] += a[j][kk]\n p += c[j]\n flag = True\n #print(t)\n for j in range(m):\n if(t[j] < x):\n flag = False\n if(flag):\n if(min_score > p):\n min_score = p\n \nif(min_score == 10000000000000):\n print(-1)\nelse:\n print(min_score)\n ', 'n, m, x = map(int, input().split())\nc = []\na = [[] for _ in range(n)]\nfor i in range(n):\n inp = list(map(int, input().split()))\n c.append(inp[0])\n for j in range(m):\n a[i].append(inp[j+1])\nkumi=1\nfor i in range(n):\n kumi *= 2\n \nmin_score = 10000000000000\nfor i in range(1, kumi):\n t = [0 for _ in range(m)]\n p = 0\n ni = format(i, \'b\').zfill(n)\n for j in range(n):\n if(ni[j]=="1"):\n for kk in range(m):\n t[kk] += a[j][kk]\n p += c[j]\n flag = True\n for j in range(m):\n if(t[j] < x):\n flag = False\n if(flag):\n if(min_score > p):\n min_score = p\n \nif(min_score == 10000000000000):\n print(-1)\nelse:\n print(min_score)\n '] | ['Wrong Answer', 'Accepted'] | ['s167293041', 's033076777'] | [9264.0, 9264.0] | [82.0, 83.0] | [716, 674] |
p02683 | u408262366 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nfrom itertools import combinations_with_replacement\n\nN,M,X = map(int,input().split())\nCA = []\nfor i in range(N):\n CA.append(list(map(int,input().split())))\n\nOK = True\nCA = np.array(CA)\nsums = np.sum(CA,axis=0)\nfor i in range(1,M+1):\n if sums[i] < X:\n OK = False\n break\n\nif OK == False:\n print(-1)\nelse:\n As = []\n for A in combinations_with_replacement(range(0, N),N):\n As.append(tuple(set(A)))\n print(As)\n As = list(map(list, set(As)))\n min_ = sums[0]\n for i in hoge:\n mini_CA = []\n for j in i:\n mini_CA.append(CA[j])\n mini_CA = np.array(mini_CA)\n OK2 = True\n sums = np.sum(mini_CA,axis=0)\n for k in range(1,M+1):\n if sums[k] < X:\n OK2 = False\n break\n if OK2 == True and sums[0] < min_:\n min_ = sums[0]\n print(min_)\n', 'import numpy as np\nfrom itertools import combinations_with_replacement\n\nN,M,X = map(int,input().split())\nCA = []\nfor i in range(N):\n CA.append(list(map(int,input().split())))\n\nOK = True\nCA = np.array(CA)\nsums = np.sum(CA,axis=0)\nfor i in range(1,M+1):\n if sums[i] < X:\n OK = False\n break\n\nif OK == False:\n print(-1)\nelse:\n As = []\n for A in combinations_with_replacement(range(0, N), r=M):\n As.append(tuple(set(A)))\n As = list(map(list, set(As)))\n last_val = sums[0]\n for ls in As:\n ls = list(set(ls))\n ans = [0] * M\n val = 0\n for a in ls:\n for ix,i in enumerate(CA[a-1][1:]):\n ans[ix] += i\n val += l[a-1][0]\n b = [i for i in ans if i >= X]\n if len(b) == len(ans):\n last_val = min(last_val, val)\n print(last_val)', 'import numpy as np\nfrom itertools import combinations_with_replacement\n\nN,M,X = map(int,input().split())\nCA = []\nfor i in range(N):\n CA.append(list(map(int,input().split())))\n\nOK = True\nCA = np.array(CA)\nsums = np.sum(CA,axis=0)\nfor i in range(1,M+1):\n if sums[i] < X:\n OK = False\n break\n\nif OK == False:\n print(-1)\nelse:\n # As = []\n # for A in combinations_with_replacement(range(0, N), r=M):\n # As.append(tuple(set(A)))\n # As = list(map(list, set(As)))\n min_ = sums[0]\n hoge = []\n kouho = list(range(1,N+1))\n for i in itertools.combinations_with_replacement(kouho, N):\n hoge.append(list(set(i)))\n hoge = list(map(list, set(map(tuple, hoge))))\n for i in hoge:\n mini_CA = []\n for j in i:\n mini_CA.append(CA[j])\n mini_CA = np.array(mini_CA)\n OK2 = True\n sums = np.sum(mini_CA,axis=0)\n for k in range(1,M+1):\n if sums[k] < X:\n OK2 = False\n break\n if OK2 == True and sums[0] < min_:\n min_ = sums[0]\n print(min_)', 'import numpy as np\nfrom itertools import combinations_with_replacement\n\nN,M,X = map(int,input().split())\nCA = []\nfor i in range(N):\n CA.append(list(map(int,input().split())))\n\nOK = True\nCA = np.array(CA)\nsums = np.sum(CA,axis=0)\nfor i in range(1,M+1):\n if sums[i] < X:\n OK = False\n break\n\nif OK == False:\n print(-1)\nelse:\n As = []\n for A in combinations_with_replacement(range(0, N),N):\n As.append(tuple(set(A)))\n As = list(map(list, set(As)))\n min_ = sums[0]\n for i in hoge:\n mini_CA = []\n for j in i:\n mini_CA.append(CA[j-1])\n mini_CA = np.array(mini_CA)\n OK2 = True\n sums = np.sum(mini_CA,axis=0)\n for k in range(1,M+1):\n if sums[k] < X:\n OK2 = False\n break\n if OK2 == True and sums[0] < min_:\n min_ = sums[0]\n print(min_)\n', 'import numpy as np\nfrom itertools import combinations_with_replacement\n\nN,M,X = map(int,input().split())\nCA = []\nfor i in range(N):\n CA.append(list(map(int,input().split())))\n\nOK = True\nCA = np.array(CA)\nsums = np.sum(CA,axis=0)\nfor i in range(1,M+1):\n if sums[i] < X:\n OK = False\n break\n\nif OK == False:\n print(-1)\nelse:\n As = []\n for A in combinations_with_replacement(range(0, N),N):\n As.append(tuple(set(A)))\n As = list(map(list, set(As)))\n min_ = sums[0]\n for i in As:\n mini_CA = []\n for j in i:\n mini_CA.append(CA[j])\n mini_CA = np.array(mini_CA)\n OK2 = True\n sums = np.sum(mini_CA,axis=0)\n for k in range(1,M+1):\n if sums[k] < X:\n OK2 = False\n break\n if OK2 == True and sums[0] < min_:\n min_ = sums[0]\n print(min_)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s007897875', 's102180971', 's376936914', 's945683239', 's613006801'] | [237488.0, 164300.0, 27248.0, 164604.0, 164792.0] | [2657.0, 1187.0, 103.0, 1178.0, 1246.0] | [804, 770, 983, 794, 789] |
p02683 | u408375121 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n, m, x = map(int, input().split())\nA = [[] for _ in range(n)]\ncost = [0] * n\nfor i in range(n):\n c_as = list(map(int, input().split()))\n cost[i], A[i] = c_as[0], c_as[1:]\nINF = 10**9\nans = INF\nfor s in range(0, 1 << n):\n smart = [0] * m\n cost_sum = 0\n for i in range(n):\n if (s >> i) % 2 == 0:\n continue\n cost_sum += c[i]\n for j in range(m):\n smart[j] += A[i][j]\n ok = True\n for j in range(m):\n if smart[j] < x:\n ok = False\n if ok:\n ans = min(ans, cost_sum)\nif ans == INF:\n ans = -1\nprint(ans)\n ', 'n, m, x = map(int, input().split())\nl = []\ndp = [[] for _ in range(n+1)]\nfor _ in range(n):\n a = list(map(int, input().split()))\n l.append(a)\ndp[0].append([0 for _ in range(m+1)])\nans = []\nfor i in range(n):\n for row in dp[i]:\n dp[i+1].append(row)\n for j in range(m+1):\n row[j] += l[i][j]\n dp[i+1].append(row)\nfor row in dp[n]:\n cnt = 0\n for j in range(1, m+1):\n if row[j] >= x:\n cnt += 1\n if cnt == m:\n ans.append(row[0])\nif len(ans) == 0:\n print(-1)\nelse:\n ans.sort()\n print(ans[0])', 'n, m, x = map(int, input().split())\nl = []\ndp = [[] for _ in range(n)]\nfor _ in range(n):\n a = list(map(int, input().split()))\n l.append(a)\ndp[0].append([0] * (m+1))\nans = []\nfor i in range(n):\n for row in dp[i]:\n dp[i+1].append(row)\n cnt = 0\n for j in range(m+1):\n if j == 0:\n row[0] += l[i][0]\n else:\n row[j] += l[i][j]\n if row[j] >= x:\n cnt += 1\n if cnt == m:\n ans.append(row[0])\n dp[i+1].append(row)\nif len(ans) == 0:\n print(-1)\nelse:\n ans.sort()\n print(ans[0])', 'n, m, x = map(int, input().split())\nl = []\ndp = [[] for _ in range(n+1)]\nfor _ in range(n):\n a = list(map(int, input().split()))\n l.append(a)\ndp[0].append([0 for _ in range(m+1)])\nans = []\nfor i in range(n):\n for row in dp[i]:\n dp[i+1].append(row)\n cnt = 0\n for j in range(m+1):\n if j == 0:\n row[0] += l[i][0]\n else:\n row[j] += l[i][j]\n if row[j] >= x:\n cnt += 1\n if cnt == m:\n ans.append(row[0])\n dp[i+1].append(row)\nif len(ans) == 0:\n print(-1)\nelse:\n ans.sort()\n print(ans[0])\n', 'n, m, x = map(int, input().split())\nA = [[] for _ in range(n)]\ncost = [0] * n\nfor i in range(n):\n c_as = list(map(int, input().split()))\n cost[i], A[i] = c_as[0], c_as[1:]\nINF = 10**9\nans = INF\nfor s in range(0, 1 << n):\n smart = [0] * m\n cost_sum = 0\n for i in range(n):\n if (s >> i) % 2 == 0:\n continue\n cost_sum += cost[i]\n for j in range(m):\n smart[j] += A[i][j]\n ok = True\n for j in range(m):\n if smart[j] < x:\n ok = False\n if ok:\n ans = min(ans, cost_sum)\nif ans == INF:\n ans = -1\nprint(ans)\n \n'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s019793499', 's331694231', 's431854462', 's519130827', 's593030120'] | [9240.0, 9252.0, 9304.0, 9360.0, 9212.0] | [25.0, 39.0, 31.0, 37.0, 85.0] | [538, 518, 531, 546, 542] |
p02683 | u419354839 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['from itertools import combinations\nimport numpy as np\nN,M,X = map(int, input().split())\n#matrix = np.array([list(map(int, input().split())) for _ in range(N)])\nmatrix = np.random.rand(12,13)\n\nmin_price = 1e9\nfor n in range(N):\n for texts in combinations(matrix, n+1):\n summation = np.sum(texts, axis=0)\n price = summation[0]\n if all(summation[1:] >= X):\n if price < min_price:\n min_price = price\n\nprint(min_price if min_price < 1e9 else -1)', 'from itertools import combinations\nimport numpy as np\nN,M,X = map(int, input().split())\nmatrix = np.array([list(map(int, input().split())) for _ in range(N)])\n\nmin_price = 1e9\nfor n in range(N):\n for texts in combinations(matrix, n+1):\n summation = np.sum(texts, axis=0)\n price = summation[0]\n if all(summation[1:] >= X):\n if price < min_price:\n min_price = price\n\nprint(min_price if min_price < 1e9 else -1)'] | ['Wrong Answer', 'Accepted'] | ['s818585547', 's902544755'] | [27244.0, 27340.0] | [142.0, 149.0] | [462, 430] |
p02683 | u423665486 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import sys\nfrom io import StringIO\nimport unittest\n\nsys.setrecursionlimit(10**5)\ndef search(n, step, rec, seq, k):\n\tif rec[n] != -1:\n\t\tc = step - rec[n]\n\t\tsim = (k - rec[n]) % c\n\t\tv = n\n\t\tfor i in range(sim):\n\t\t\tv = seq[v-1]\n\t\tprint(v)\n\t\treturn\n\trec[n] = step\n\tsearch(seq[n-1], step + 1, rec, seq, k)\n\ndef resolve():\n\tn, k = map(int, input().split())\n\tseq = list(map(int, input().split()))\n\trec = [-1]*(n+1)\n\tsearch(1, 0, rec, seq, k)\nresolve()', "def resolve():\n\tn, m, x = map(int, input().split())\n\tc_seq = []\n\ta_seq = []\n\tans = float('inf')\n\tfor i in range(n):\n\t\tc, *a = map(int, input().split())\n\t\tc_seq.append(c)\n\t\ta_seq.append(a)\n\tfor i in range(1 << n):\n\t\tpay = 0\n\t\tskill = [0]*m\n\t\tfor j in range(n):\n\t\t\tif i >> j & 1:\n\t\t\t\tpay += c_seq[j]\n\t\t\t\tfor k in range(m):\n\t\t\t\t\tskill[k] += a_seq[j][k]\n\t\tok = True\n\t\tfor y in skill:\n\t\t\tif x > y:\n\t\t\t\tok = False\n\t\tif ok:\n\t\t\tans = min(ans, pay)\n\tprint(ans if ans < float('inf') else -1)\nresolve()"] | ['Runtime Error', 'Accepted'] | ['s053120366', 's128665884'] | [16152.0, 9216.0] | [65.0, 61.0] | [444, 491] |
p02683 | u432754124 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x = map(input().split())\n\nmin_money = 999999999999\nfor i in range(2**n):\n\tbag = []\n\ta = list(map(int,input().split()))\n\tfor j in range(n):\n\t\tif ((i >> j) & 1):\n\t\t\tbag.append(a)\n\n\tmoney = 0\n\tskill = [0] * m\n\tenogh = [0] * m\n\tfor sub in bag:\n\t\tmoney += sub[0]\n\t\tfor k in range(1,m+1):\n\t\t\tskill[k-1] += sub[k]\n\t\t\tif skill[k-1] >= x:\n\t\t\t\tenough[k-1] = 1\n\n\tif 0 not in enough and min_money > money:\n\t\tmin_money = money\n\nif min_money != 999999999999:\n\tprint(min_money)\nelse:\n\tprint(-1)\n', 'n,m,x = map(int, input().split())\n\nmin_money = 999999999\n\nl=[]\nfor i in range(n):\n\ta=list(map(int,input().split()))\n\tl.append(a)\n\nfor i in range(2**n):\n\tbag = []\n\tfor j in range(n):\n\t\tif ((i >> j) & 1):\n\t\t\tbag.append(l[j])\n\n\tmoney = 0\n\tskill = [0] * m\n\tenough = [0] * m\n\tfor sub in bag:\n\t\tmoney += sub[0]\n\t\tfor k in range(1,m+1):\n\t\t\tskill[k-1] += sub[k]\n\t\t\tif skill[k-1] >= x:\n\t\t\t\tenough[k-1] = 1\n\n\tif 0 not in enough and min_money > money:\n\t\tmin_money = money\n\nif min_money != 999999999:\n\tprint(min_money)\nelse:\n\tprint(-1)'] | ['Runtime Error', 'Accepted'] | ['s636007405', 's711507785'] | [9044.0, 9136.0] | [24.0, 108.0] | [484, 523] |
p02683 | u436173409 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['\nn, m, x = [int(e) for e in input().split()]\n\nimport numpy as np\n\nall = np.zeros(n*(m+1)).reshape(n,m+1)\n\nfor i in range(n):\n all[i] += [int(e) for e in input().split()]\n\nbool_list = np.array([])\na = []\nb = []\ndef make(n):\n if len(a) == n:\n b.append([0 for _ in range(n)])\n for i,v in enumerate(a) :\n if v == True:\n b[-1][i] = True\n else:\n b[-1][i] = False\n else:\n for i in [True,False]:\n a.append(i)\n make(n)\n a.pop()\n\nmake(n)\nc=np.array(b)\n\ndp=[10**10]\n\nfor i in c:\n if all[i][:,1].sum(axis = 0) >=x :\n dp = min(dp,all[i][:,0].sum(axis = 0))\n\nif dp ==[10**10]:\n dp = [-1]\nprint(int(dp[0]))', 'n, m, x = [int(e) for e in input().split()]\n\nimport numpy as np\nimport itertools\n\nall = np.zeros(n*(m+1)).reshape(n,m+1)\n\nfor i in range(n):\n all[i] += [int(e) for e in input().split()]\n\nb = itertools.product([True,False],repeat=n)\n\ndp=10**10\n\nfor i in b:\n i = np.array(i)\n if (all[i][:,1:].sum(axis = 0) >=x).all() :\n dp = min(dp,all[i][:,0].sum(axis = 0))\n\nif dp ==10**10:\n dp = -1\nprint(int(dp))'] | ['Runtime Error', 'Accepted'] | ['s178480176', 's371472222'] | [27524.0, 27144.0] | [153.0, 161.0] | [719, 417] |
p02683 | u440129511 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x=map(int,input().split())\nc=list(map(int,input().split()) for _ in range(n))\nl=[]*n\nfor i in range(n):\n b=[0,0]\n b[0]+=i+1\n b[1]+=a[i]\n l.append(b)\nc=0\nne=0\nl1=[0]*n\nwhile True:\n if c==k:\n print(l[ne][1])\n exit()\n ne+=-ne+l[ne][1]-1\n c+=1\n if l1[ne]==0:l1[ne]+=1\n else:break\n\nroop_c=0\nwhile True:\n if c+roop_c==k:\n print(l[ne][1])\n exit()\n if l1[ne]==1:l1[ne]+=1\n else:break\n ne+=-ne+l[ne][1]-1\n roop_c+=1\n\nre=(k-c)%roop_c\nif re==0:print(l[ne][0])\nelse:\n for i in range(re):\n if i==re-1:print(l[ne][1])\n ne+=-ne+l[ne][1]-1', "n,m,x=map(int,input().split())\nc=list(map(int,input().split()))\nl=[]\nfor i in range(2**n):\n l.append(format(i,'b').zfill(n))\nl1=[]\nfor i in range(len(l)):\n s=[0]*(m+1)\n for j in range(n):\n if l[i][j]=='1':\n for k in range(m+1):\n s[k]+=c[j][k]\n\n for o in range(1,m+1):\n if s[o]<x:break\n if o==m:l1.append(s[0])\nif len(l1)==0:print(-1) \nelse:print(min(l1))", "n,m,x=map(int,input().split())\nc=[list(map(int,input().split())) for _ in range(n)]\nl=[]\nfor i in range(2**n):\n l.append(format(i,'b').zfill(n))\nl1=[]\nfor i in range(len(l)):\n s=[0]*(m+1)\n for j in range(n):\n if l[i][j]=='1':\n for k in range(m+1):\n s[k]+=c[j][k]\n\n for o in range(1,m+1):\n if s[o]<x:break\n if o==m:l1.append(s[0])\nif len(l1)==0:print(-1) \nelse:print(min(l1))"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s083933883', 's794765762', 's850465336'] | [9288.0, 9324.0, 9332.0] | [20.0, 21.0, 87.0] | [614, 413, 433] |
p02683 | u443151804 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['from itertools import product as pr\nn,m,x=[int(i) for i in input().split()]\nl=[[int(i) for i in input().split()]for j in range(n)]\np=list(pr([0,1],repeat=n))\nsuml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]\nans=min([i[0] for i in suml if all([i[j] >=x for j in range(1,6)])])\nprint(ans)', 'from itertools import *\nn,m,x=[int(i) for i in input().split()]\nl=[[int(i) for i in input().split()] for j in range(n)]\nc=[i[0] for i in l]\nl=[i[1:] for i in l]\np=list(product([0,1],repeat=m))\ns=[[sum([l[k][j]*i[j] for k in range(n)]) for j in range(m)] for i in p]\nprint(s)\ns=[c[i] for i in range(n) if all([s[i][j]>=x for j in range(m)])]\nprint(s)', 'from itertools import product as pr\nn,m,x=[int(i) for i in input().split()]\nl=[[int(i) for i in input().split()]for j in range(n)]\np=list(pr([0,1],repeat=n))\nsuml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]\nans=[i[0] for i in suml if all([i[j] >=x for j in range(1,m+1)])]\nif len(ans)==0:\n print(-1)\nelse:\n print(min(ans))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s582074726', 's764750352', 's101650469'] | [12116.0, 11884.0, 12116.0] | [111.0, 103.0, 113.0] | [313, 349, 351] |
p02683 | u444481227 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["n,m,x = map(int,input().split())\n\nca=[list(map(int,input().split())) for _ in range(n)]\n\nres=float('inf')\n\nfor i in range(2**n):\n sc=0\n a=[0]*m\n for j in range(n):\n if ((i >> j) & 1) :\n sc=+ca[j][0]\n a+=ca[j][1:]\n if min(a)>=x:\n res=min (sc,res)\n\nif res == INF:\n print(-1)\nelse:\n print(res)\n", "n,m,x = map(int,input().split())\n\nca=[list(map(int,input().split())) for _ in range(n)]\n\nres=float('inf')\n\nfor i in range(2**n):\n sc=0\n a=[0]*m\n for j in range(n):\n if ((i >> j) & 1) :\n sc+=ca[j][0]\n for k in range(m):\n a[k]+=ca[j][k+1]\n if min(a)>=x:\n res=min(sc,res)\n\nif res == float('inf'):\n print(-1)\nelse:\n print(res)\n"] | ['Runtime Error', 'Accepted'] | ['s249501500', 's211101052'] | [9212.0, 9140.0] | [41.0, 83.0] | [317, 356] |
p02683 | u447899880 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['(n,m,x)=map(int,input().split())\nc=list()\na=list()\nfor i in range(n):\n line=list(map(int,input().split()))\n c.append(line.pop(0))\n a.append(line)\n\nresult=list()\nfor i in range(2**n):\n total=[0]*m\n cost=0\n for k in range(n):\n if bin(i)[k]=="1":\n total+=a[k]\n cost+=int(c[k])\n if total>=[x]*m:\n result.append(cost)\n\nif result!=[]:\n print(min(result))\nelse:\n print(-1)', '(n,m,x)=map(int,input().split())\nc=list()\na=list()\nfor i in range(n):\n line=map(int,input().split())\n c.apppend(line.pop(c[0]))\n a.append(line)\n\nfor i in range(2**n):\n total=[0]*m\n cost=0\n for k in range(n):\n if int(bin(i)[k])==1:\n total+=a[k]\n cost+=c[k]\n if total>=[x]*m:\n result.append(cost)\n\nif result!=None:\n print(min(cost))\nelse:\n print(-1)', 'import numpy as np\n(n,m,x)=map(int,input().split())\n\na=list()\nfor i in range(n):\n line=list(map(int,input().split()))\n a.append(line)\n\na=np.array(a)\nresult=np.array([[0]*(m+1)])\nfor i in range(n):\n l=list()\n for j in range(len(result)):\n l.append(a[i]+result[j])\n l.append(result[j])\n result=np.array(l)\n\nc=list()\nh=[x]*m\nfor line in result:\n if np.all(line[1:]>=h):\n c.append(line[0])\nif len(c)==0:\n print(-1)\nelse:\n print(min(c))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s647183761', 's957030835', 's232471178'] | [9192.0, 9072.0, 28248.0] | [25.0, 24.0, 133.0] | [390, 372, 476] |
p02683 | u449473917 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x=map(int,input().split())\nl=[]\n\nfor i in range(n):\n a=list(map(int,input().split()))\n l.append(a)\nprint(l)\nans=99999999\nfor i in range(2 ** n):\n bag = []\n for j in range(n): \n if ((i >> j) & 1): \n bag.append(l[j]) \n skill=[0]*m\n enou=[0]*m\n mone=0\n for sub in bag:\n mone+=sub[0]\n for kk in range(1,m):\n skill[kk-1]+=sub[kk]\n if skill[kk-1]>=x:\n enou[kk-1]+=1\n if sum(enou)==m:\n if ans>mone:\n ans=mone\nif ans==99999999:\n print(-1)\nelse:\n print(ans)', 'n,m,x=map(int,input().split())\nl=[]\n\nfor i in range(n):\n a=list(map(int,input().split()))\n l.append(a)\nans=99999999\nfor i in range(2 ** n):\n bag = []\n for j in range(n): \n if ((i >> j) & 1): \n bag.append(l[j]) \n skill=[0]*m\n enou=[0]*m\n mone=0\n for sub in bag:\n mone+=sub[0]\n for kk in range(1,m+1):\n skill[kk-1]+=sub[kk]\n if skill[kk-1]>=x:\n enou[kk-1]+=1\n if 0 not in enou:\n if ans>mone:\n ans=mone\nif ans==99999999:\n print(-1)\nelse:\n print(ans)'] | ['Wrong Answer', 'Accepted'] | ['s260926377', 's505515913'] | [9248.0, 9136.0] | [116.0, 115.0] | [574, 568] |
p02683 | u449580152 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nn, m, x = map(int, input().split())\nBook = [list(map(int, input().split())) for _ in range(n)]\nselect = [np.array([])]*(2**n)\ncost = [0]*(2**n)\nskill = [np.array([0]*m)]*(2**n)\ncost2 = []\nfor i in range(2**n):\n for j in range(n):\n if (i >> j) & 1:\n cost[i] += Book[j][0]\n skill[i] += np.array(Book[j])[1:m+1]\n if np.min(skill[i]) >= x:\n cost2.append(cost[i])\nif len(cost2) > 0:\n print(min(cost2))\nelse:\n print(-1)', 'import numpy as np\nn, m, x = map(int, input().split())\nBook = [list(map(int, input().split())) for _ in range(n)]\ncost = [0 for _ in range(2**n)]\nskill = [np.zeros(m) for _ in range(2**n)]\ncost2 = []\nfor i in range(2**n):\n for j in range(n):\n if (i >> j) & 1:\n cost[i] += Book[j][0]\n skill[i] += np.array(Book[j])[1:m+1]\n if np.min(skill[i]) >= x:\n cost2.append(cost[i])\nif cost2:\n print(min(cost2))\nelse:\n print(-1)'] | ['Wrong Answer', 'Accepted'] | ['s344878706', 's471101504'] | [27504.0, 27904.0] | [215.0, 216.0] | [480, 464] |
p02683 | u449822557 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\nn, m, x = list(map(int,input().split()))\nc = []\nfor i in range(n):\n c.append(list(map(int,input().split())))\nmn = 0\nfor bn in itertools.product([0,1], repeat=n):\n money = 0\n skills = [0]*m\n for j in range(n):\n if bn[j] == 1:\n money += c[j][0]\n for k in range(m):\n skills[k] += c[j][k+1]\n if all([y > x for y in skills]):\n if mn == -1:\n mn = money\n elif money < mn:\n mn = money\nprint(mn)', 'import itertools\nn, m, x = list(map(int,input().split()))\nc = []\nfor i in range(n):\n c.append(list(map(int,input().split())))\nmn = -1\nfor bn in itertools.product([0,1], repeat=n):\n money = 0\n skills = [0]*m\n for j in range(n):\n if bn[j] == 1:\n money += c[j][0]\n for k in range(m):\n skills[k] += c[j][k+1]\n if all([y >= x for y in skills]):\n if mn == -1:\n mn = money\n elif money < mn:\n mn = money\nprint(mn)'] | ['Wrong Answer', 'Accepted'] | ['s611675301', 's517162265'] | [9216.0, 9100.0] | [90.0, 84.0] | [498, 500] |
p02683 | u458590500 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['#coding :utf-8\nimport numpy as np\n\nN,M,X=map(int,input().split())\na=[]\nfor i in range(N):\n a.append(list(map(int,input().split())))\n\nsuma=sum(a[0][])\nprint(suma,a)', '#coding :utf-8\n\nN,M,X=map(int,input().split())\n\nC=[]\nA=[]\nfor i in range(N):\n t=list(map(int,input().split()))\n C.append(t[0])\n A.append(t[1:])\nresult=-1\n\nfor i in range(1<<N):\n t=[0]*M\n c=0\n for j in range(N):\n if ((i>>j) & 1==0):\n continue\n c+=C[j]\n for k in range(M):\n t[k]+=A[j][k]\n \n \n if all(x>=X for x in t):\n if result==-1:\n result=c\n else:\n result=min(result,c)\n\nprint(result)'] | ['Runtime Error', 'Accepted'] | ['s396328468', 's009212024'] | [8964.0, 9192.0] | [25.0, 84.0] | [166, 431] |
p02683 | u458725980 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['N, M, X = map(int,input().split())\n\nCAM = list([list(map(int,input().split())) for i in range(N)])\n# print(CAM)\nminn = 10**18\nb = False\n\nfor i in range(2 ** N):\n s = 0\n am = []\n\n for j in range(N): \n if ((i >> j) & 1): \n am.append(CAM[j])\n\n j = False\n sss = [0] * (M+1)\n for kk in range(len(am)):\n s += am[kk][0]\n for m in range(0, M):\n sss[m+1] += am[kk][m+1]\n \n if len([i for i in sss[1:] if i >= X] ) == len(sss[1:]):\n b = True\n minn = min(s,minn)\n \n print(sss)\n # if x >= X and y >= X and z >= X:\n \n # b = True\n\nprint(minn if b == True else -1)', 'N, M, X = map(int,input().split())\n\nCAM = list([list(map(int,input().split())) for i in range(N)])\n# print(CAM)\nminn = 10**18\nb = False\n\nfor i in range(2 ** N):\n s = 0\n am = []\n\n for j in range(N): \n if ((i >> j) & 1): \n am.append(CAM[j])\n\n j = False\n sss = [0] * (M+1)\n for kk in range(len(am)):\n s += am[kk][0]\n for m in range(0, M):\n sss[m+1] += am[kk][m+1]\n \n if len([i for i in sss[1:] if i >= X] ) == len(sss[1:]):\n b = True\n minn = min(s,minn)\n \n # print(sss)\n # if x >= X and y >= X and z >= X:\n \n # b = True\n\nprint(minn if b == True else -1)'] | ['Wrong Answer', 'Accepted'] | ['s653447305', 's290601599'] | [9256.0, 9188.0] | [105.0, 90.0] | [722, 724] |
p02683 | u459215900 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import sys\ninput = sys.stdin.readline\nimport itertools\n\nN, M, X = map(int, input().split())\nvalues_list = []\nfor i in range(N):\n values = list(map(int, input().split()))\n values_list.append(values)\n\nans = 999999\nfor i in range(1, N+1):\n for pair in itertools.combinations(values_list, i):\n this_m_dict = {}\n this_cost = 0\n for item in pair:\n for j in range(1, M+1):\n this_m_dict[j] = this_m_dict.get(j, 0) + item[j]\n this_cost += item[0]\n for myvalue in this_m_dict.values():\n if myvalue < X:\n break\n ans = min(this_cost, ans)\n\nprint(ans)', 'import sys\ninput = sys.stdin.readline\nimport itertools\n\nN, M, X = map(int, input().split())\nvalues_list = []\nfor i in range(N):\n values = list(map(int, input().split()))\n values_list.append(values)\n\n\nfor i in range(1, N+1):\n for pair in itertools.combinations(values_list, i):\n this_m_dict = {}\n this_cost = 0\n for item in pair:\n for j in range(1, M+1):\n this_m_dict[j] = this_m_dict.get(j, 0) + item[j]\n this_cost += item[0]\n for myvalue in this_m_dict.values():\n if myvalue < X:\n break\n ans = min(this_cost, ans)\n\nprint(ans)', "import sys\ninput = sys.stdin.readline\nimport itertools\n\n\n# N, M, X = map(int, input().split())\n# values_list = []\n\n# values = list(map(int, input().split()))\n# values_list.append(values)\n\n# ans = 0\n\n# for pair in itertools.combinations(values_list, i):\n# this_m_dict = {}\n# this_cost = 0\n# for item in pair:\n# for j in range(1, M+1):\n# this_m_dict[j] = this_m_dict.get(j, 0) + item[j]\n# this_cost += item[0]\n# for myvalue in this_m_dict.values():\n# if myvalue < X:\n# break\n# ans = min(this_cost, ans)\n\nN, M, X = map(int, input().split())\nA = []\nC = []\n\nfor i in range(N):\n values = list(map(int, input().split()))\n C.append(values[0])\n A.append(values[1:])\n\nINF = float('INF')\nmin_cost = INF\n\ndef dfs(i, cost, learn):\n if i == N:\n if min(learn) >= X: \n return cost\n else:\n return INF\n\n else:\n new_learn = [(x+y) for (x, y) in zip(A[i], learn)]\n cost = min(dfs(i+1, cost, learn), dfs(i+1, cost + C[i], new_learn))\n return cost\n\nmin_cost = dfs(0, 0, [0] * M)\n\nif min_cost == INF:\n print(-1)\nelse:\n print(min_cost)"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s089209007', 's484511063', 's599895089'] | [9212.0, 9164.0, 9160.0] | [82.0, 24.0, 29.0] | [645, 633, 1274] |
p02683 | u460386402 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["n,m,x=map(int,input().split())\nc=[list(map(int,input().split())) for i in range(n)]\nans=10**9\n\nfor i in range(2**n):\n b=[0]*m\n count=0\n en=0\n for j in range(n):\n if (i>>j)&1:\n en=en+c[j][0]\n for f in range(m):\n b[f]+=c[j][f+1]\n for f in range(m):\n if b[f]>=x:\n count+=1\n print(b[f])\n if count==m:\n if en<ans:\n ans=en\n\nif ans==10**9:\n print('-1')\nelse:print(ans)", 'n,m,x=map(int,input().split())\na=[]\nc=[]\ninf=10**9\nresult=inf\nfor i in range(n):\n b=list(map(int,input().split()))\n c.append(b[0])\n a.append(b[1:])\n \nfor i in range(1<<n):\n cnt=0\n rikaido=[0]*m\n for j in range(n):\n if (i>>j)&1:\n for k in range(m):\n rikaido[k]+=a[j][k]\n cnt+=c[j]\n else:\n pass\n if min(rikaido)>=x:\n result=min(result,cnt)\n\nif result==inf:\n print(-1)\nelse:\n print(result)', 'n,m,x=map(int,input().split())\na=[]\nc=[]\ninf=10**9\nresult=inf\nfor _ in range(n):\n books=list(map(int,input().split()))\n c.append(books[0])\n a.append(books[1:])\n \nfor i in range(1<<n):\n cnt=0\n rikaido=[0]*m\n for j in range(n):\n if (i>>j)&1:\n for k in range(m):\n rikaido[k]+=a[j][k]\n cnt+=c[j]\n else:\n pass\n if min(rikaido)>=x:\n result=min(result,cnt)\n\nif result==inf:\n print(-1)\nelse:\n print(result)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s547083617', 's711521870', 's005630231'] | [9272.0, 9188.0, 9172.0] | [214.0, 104.0, 80.0] | [443, 437, 448] |
p02683 | u463068683 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x = (int(x) for x in input().split())\n\nla=[]\nfor i in range(n):\n la.append(list(map(int, input().split())))\n\ny = 0\nfor i in range(2 ** n):\n lb = [0]*(m+1)\n for j in range(n):\n if ((i >> j) & 1):\n lb = [x + y for (x, y) in zip(lb, la[j][:])] \n frg=1\n print(lb)\n for h in range(m):\n if lb[h+1]<x:\n frg=0\n if frg==1:\n if lb[0] <= y or y==0:\n y=lb[0]\n print(y)\n del lb[:]\nprint(y if y>0 else -1)', 'n,m,x = (int(x) for x in input().split())\n\nla=[]\nfor i in range(n):\n la.append(list(map(int, input().split())))\n\ny = 0\nfor i in range(2 ** n):\n lb = [0]*(m+1)\n for j in range(n):\n if ((i >> j) & 1):\n lb = [x + y for (x, y) in zip(lb, la[j][:])] \n frg=1\n for h in range(m):\n if lb[h+1]<x:\n frg=0\n if frg==1:\n if lb[0] <= y or y==0:\n y=lb[0]\n del lb[:]\nprint(y if y>0 else -1)'] | ['Wrong Answer', 'Accepted'] | ['s912133975', 's133250431'] | [9264.0, 9016.0] | [71.0, 62.0] | [428, 405] |
p02683 | u466143662 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["from itertools import product\nn, m, x = map(int, input().split())\ncosts = []\ngets = []\nfor i in range(n):\n cost, *argo = map(int, input().split())\n costs.append(cost)\n gets.append(argo)\n\n \nbits_list = list(product([0,1], repeat=n))\nmin_cost = float('inf')\ncnt = 0\nfor bits in bits_list:\n tmp_cost = 0\n tmp_argo = [0] * m\n for i, v in enumerate(bits):\n if v:\n tmp_cost += costs[i]\n for j, p in enumerate(gets[i]):\n tmp_argo[j] += p\n \n if all(map(lambda X:X>x, tmp_argo)):\n min_cost = min(min_cost, tmp_cost)\n cnt = 1\nif cnt:\n print(min_cost)\nelse:\n print(-1)", "from itertools import product\nn, m, x = map(int, input().split())\ncosts = []\ngets = []\nfor i in range(n):\n cost, *argo = map(int, input().split())\n costs.append(cost)\n gets.append(argo)\n\n \nbits_list = list(product([0,1], repeat=n))\nmin_cost = float('inf')\ncnt = 0\nfor bits in bits_list:\n tmp_cost = 0\n tmp_argo = [0] * m\n for i, v in enumerate(bits):\n if v:\n tmp_cost += costs[i]\n for j, p in enumerate(gets[i]):\n tmp_argo[j] += p\n \n if all(map(lambda X:X>=x, tmp_argo)):\n min_cost = min(min_cost, tmp_cost)\n cnt = 1\nif cnt:\n print(min_cost)\nelse:\n print(-1)"] | ['Wrong Answer', 'Accepted'] | ['s212397812', 's370233520'] | [9656.0, 9616.0] | [72.0, 69.0] | [660, 661] |
p02683 | u479353489 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['from itertools import combinations\nfrom collections import defaultdict\nN, M , X = map(int, input().split())\nC = [0 for i in range(N)]\nD = defaultdict(list)\nans = 12345678\n\nfor i in range(N):\n temp = list(map(lambda x:int(x), input().split()))\n C[i] = temp[0]\n D[C[i]] = temp[1:]\n\ndef solve():\n global ans\n combs = []\n for i in range(N+1):\n combs.extend(combinations(C,i))\n\n # Total: O(2^N*N*M)\n for comb in combs: #O(2^N)\n L = [0 for i in range(M)]\n cost = 0\n ok = True\n\n for k in comb: #O(N)\n cost += k\n for i in range(M): #O(M)\n L[i] += D[k][i]\n print(comb, L, cost)\n for i in range(M):\n if L[i] < X: \n ok = False\n \n if ok:\n ans = min(ans,cost)\n\n if ans == 12345678:\n print(-1)\n else:\n print(ans)\nsolve()\n', "N, M , X = map(int, input().split())\nC = [0 for i in range(N)]\nA = [[]for i in range(N)]\n\n\nfor i in range(N):\n temp = list(map(lambda x:int(x), input().split()))\n C[i] = temp[0]\n A[i] = temp[1:]\n\ndef solve():\n ans = float('inf')\n # Total: O(2^N*N*M)\n total = 1 << N\n for mask in range(total): #O(2^N)\n L = [0 for i in range(M)]\n cost = 0\n \n for i in range(N): #O(N)\n if (mask >> i) & 1:\n cost += C[i]\n for j in range(M): #O(M)\n L[j] += A[i][j]\n \n ok = True\n for i in range(M):\n if L[i] < X: \n ok = False\n print(L, cost, ok)\n if ok:\n ans = min(ans,cost)\n\n if ans == float('inf'):\n print(-1)\n else:\n print(ans)\nsolve()\n", "N, M , X = map(int, input().split())\nC = [0 for i in range(N)]\nA = [[]for i in range(N)]\n\n\nfor i in range(N):\n temp = list(map(lambda x:int(x), input().split()))\n C[i] = temp[0]\n A[i] = temp[1:]\n\ndef solve():\n ans = float('inf')\n # Total: O(2^N*N*M)\n total = 1 << N\n for mask in range(total): #O(2^N)\n L = [0 for i in range(M)]\n cost = 0\n \n for i in range(N): #O(N)\n if (mask >> i) & 1:\n cost += C[i]\n for j in range(M): #O(M)\n L[j] += A[i][j]\n \n ok = True\n for i in range(M):\n if L[i] < X: \n ok = False\n #print(L, cost, ok)\n if ok:\n ans = min(ans,cost)\n\n if ans == float('inf'):\n print(-1)\n else:\n print(ans)\nsolve()\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s235128525', 's988337548', 's871883287'] | [9688.0, 9256.0, 9300.0] | [76.0, 73.0, 65.0] | [894, 824, 825] |
p02683 | u479719434 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nfrom itertools import product\nINF = 10**9\n\nN, M, X = map(int, input().split())\nC = [None]*N\nA = [None]*N\nfor i in range(N):\n line = list(map(int, input().split()))\n C[i] = line[0]\n A[i] = np.array(line[1:])\n\nchoose = [True, False]\n\nmin_price = INF\n\nfor s in product([True, False], repeat=N):\n price = 0\n knowledge = np.zeros(M)\n for i in range(N):\n if s >> i & 1:\n knowledge += A[i]\n price += C[i]\n if np.any(knowledge < X):\n continue\n if min_price == -1:\n min_price = price\n min_price = min(min_price, price)\n\nif min_price == INF:\n print(-1)\nelse:\n print(min_price)\n', 'import numpy as np\nfrom itertools import product\nINF = 10**9\n\nN, M, X = map(int, input().split())\nC = [None]*N\nA = [None]*N\nfor i in range(N):\n line = list(map(int, input().split()))\n C[i] = line[0]\n A[i] = np.array(line[1:])\n\nchoose = [True, False]\n\nmin_price = INF\n\nfor s in product([True, False], repeat=N):\n price = 0\n knowledge = np.zeros(M)\n for i in range(N):\n if s[i]:\n knowledge += A[i]\n price += C[i]\n if np.any(knowledge < X):\n continue\n if min_price == -1:\n min_price = price\n min_price = min(min_price, price)\n\nif min_price == INF:\n print(-1)\nelse:\n print(min_price)\n'] | ['Runtime Error', 'Accepted'] | ['s831025696', 's305280488'] | [27204.0, 27240.0] | [103.0, 160.0] | [662, 656] |
p02683 | u481250941 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['#\n# abc167 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\nfrom collections import deque\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = """3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9"""\n output = """120"""\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = """3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5"""\n output = """-1"""\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = """8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2"""\n output = """1067"""\n self.assertIO(input, output)\n\n\ndef resolve_bit():\n N, M, X = map(int, input().split())\n CA = [list(map(int, input().split())) for _ in range(N)]\n\n ans = float("inf")\n for bit in range(1 << N):\n S = [0]*(M+1)\n for i, ca in enumerate(CA):\n if (1 << i) & bit == 1 << i:\n S = list(map(sum, zip(S, ca)))\n for s in S[1:]:\n if s < X:\n break\n else:\n ans = min(ans, S[0])\n\n if ans == float("inf"):\n ans = -1\n\n print(ans)\n\n\ndef resolve():\n global N, M, X, CA\n N, M, X = map(int, input().split())\n CA = [list(map(int, input().split())) for _ in range(N)]\n\n b = deque()\n ans = dfs(0, b)\n if ans == float("inf"):\n ans = -1\n\n print(ans)\n\n\ndef dfs(n, B):\n if n == N:\n S = [0]*(M+1)\n for i, ca in enumerate(CA, 1):\n if i in B:\n S = list(map(sum, zip(S, ca)))\n for s in S[1:]:\n if s < X:\n return float("inf")\n else:\n return S[0]\n\n ans = float("inf")\n B.append(n+1)\n tmp = dfs(n+1, B)\n ans = min(ans, dfs(n+1, B))\n B.pop()\n ans = min(ans, dfs(n+1, B))\n\n return ans\n\n\nif __name__ == "__main__" ans = min(ans, tmp):\n # unittest.main()\n resolve()\n', '#\n# abc167 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\nfrom collections import deque\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = """3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9"""\n output = """120"""\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = """3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5"""\n output = """-1"""\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = """8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2"""\n output = """1067"""\n self.assertIO(input, output)\n\n\ndef resolve():\n N, M, X = map(int, input().split())\n CA = [list(map(int, input().split())) for _ in range(N)]\n\n ans = float("inf")\n for bit in range(1 << N):\n S = [0]*(M+1)\n for i, ca in enumerate(CA):\n if (1 << i) & bit == 1 << i:\n S = list(map(sum, zip(S, ca)))\n if min(S[1:]) < X:\n \tbreak\n ans = min(ans, S[0])\n\n if ans == float("inf"):\n ans = -1\n\n print(ans)\n\n\nif __name__ == "__main__":\n # unittest.main()\n resolve()\n', '#\n# abc167 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\nfrom collections import deque\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = """3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9"""\n output = """120"""\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = """3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5"""\n output = """-1"""\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = """8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2"""\n output = """1067"""\n self.assertIO(input, output)\n\n\ndef resolve():\n N, M, X = map(int, input().split())\n CA = [list(map(int, input().split())) for _ in range(N)]\n\n ans = float("inf")\n for bit in range(1 << N):\n S = [0]*(M+1)\n for i, ca in enumerate(CA):\n if (1 << i) & bit == 1 << i:\n S = list(map(sum, zip(S, ca)))\n if min(S[1:]) >= X:\n ans = min(ans, S[0])\n\n if ans == float("inf"):\n ans = -1\n\n print(ans)\n\n\ndef resolve_dfs():\n global N, M, X, CA\n N, M, X = map(int, input().split())\n CA = [list(map(int, input().split())) for _ in range(N)]\n\n b = deque()\n ans = dfs(0, b)\n if ans == float("inf"):\n ans = -1\n\n print(ans)\n\n\ndef dfs(n, B):\n if n == N:\n S = [0]*(M+1)\n for i, ca in enumerate(CA, 1):\n if i in B:\n S = list(map(sum, zip(S, ca)))\n if min(S[1:]) < X:\n return float("inf")\n else:\n return S[0]\n\n ans = float("inf")\n B.append(n+1)\n ans = min(ans, dfs(n+1, B))\n B.pop()\n ans = min(ans, dfs(n+1, B))\n\n return ans\n\n\nif __name__ == "__main__":\n # unittest.main()\n resolve()\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s431085332', 's889888862', 's833900561'] | [9148.0, 16224.0, 16232.0] | [26.0, 74.0, 114.0] | [2257, 1508, 2135] |
p02683 | u486074261 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['from sys import stdin\nn, m, x = [int(x) for x in stdin.readline().rstrip().split()]\nc = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]\n\nc.sort()\nmi = -1\n\nfor i in range(len(c)-1):\n _li = [x for x in c[i] if x != c[i][0]]\n mon = c[i][0]\n\n for j in range(i + 1, len(c)):\n li = [_li[k] + c[j][k + 1] for k in range(len(_li))]\n mon += c[j][0]\n if sum(1 for k in li if k >= x) == m:\n if mi > mon or mi == -1:\n mi = mon\n break\n else:\n _li = li\n\n\nprint(mi)', 'from sys import stdin\nimport itertools\n\nn, m, x = [int(x) for x in stdin.readline().rstrip().split()]\nc = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]\nc.sort()\nmi = -1\nr = 0\n\nfor j in range(1, m + 1):\n li = [x[j] for x in c]\n li.sort(reverse=True)\n for i in range(len(li)):\n if sum(li[:i]) >= x:\n r = max(r, i)\n break\n\nfor h in range(r,n):\n for i in itertools.combinations(c, h):\n cnt = [0] * m\n mon = 0\n for j in i:\n cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]\n mon += j[0]\n print(cnt) \n if sum(1 for k in cnt if k >= x) == m:\n if mi > mon or mi == -1:\n\n mi = mon\n break\n\nprint(mi)\n', 'from sys import stdin\nimport itertools\n\nn, m, x = [int(x) for x in stdin.readline().rstrip().split()]\nc = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]\nc.sort()\nmi = -1\nr = 0\n\nfor j in range(1, m + 1):\n li = [x[j] for x in c]\n li.sort(reverse=True)\n for i in range(1, len(li) + 1):\n if sum(li[:i]) >= x:\n r = max(r, i)\n break\n\nfor h in range(r, n + 1):\n for i in itertools.combinations(c, h):\n cnt = [0] * m\n mon = 0\n for j in i:\n cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]\n mon += j[0]\n if sum(1 for k in cnt if k >= x) == m:\n if mi > mon or mi == -1:\n\n mi = mon\n break\n\nprint(mi)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s594456747', 's998108581', 's229927114'] | [9244.0, 9164.0, 9168.0] | [25.0, 104.0, 76.0] | [553, 773, 750] |
p02683 | u488178971 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['# ABC 167 C\nN,M,X = map(int,input().split())\nC =[]\nfor m in range(N):\n C.append([int(i) for i in input().split()])\nC.sort(key=lambda x:x[0])\n\nfrom itertools import combinations\nimport numpy as np\n\n\nans = 10**5 +1\n\nfor m in range(1,N+1):\n P=list(combinations(C,m))\n print(P)\n tmp =np.sum(P,axis=1)\n for t in tmp:\n\n if min(t[1:])>=X and ans > t[0]:\n ans = t[0]\n print(t)\n \n \nif min(t[1:])<X:\n print(-1)\nelse:\n print(ans)', '# ABC 167 C\nN,M,X = map(int,input().split())\nC =[]\nfor m in range(N):\n C.append([int(i) for i in input().split()])\nC.sort(key=lambda x:x[0])\n\nfrom itertools import combinations\nimport numpy as np\n\nans = 10**5 +1\n\nfor m in range(1,M+1):\n P=list(combinations(C,m))\n tmp =np.sum(P,axis=1)\n if ans < tmp[0,0]:\n print(ans)\n exit()\n elif min(tmp[0,1:])>=X and ans > tmp[0,0]:\n ans = tmp[0,0]\n\n\nif min(tmp[0,1:])<X:\n print(-1)\nelse:\n print(ans)\n', '# ABC 167 C\nN,M,X = map(int,input().split())\nC =[]\nfor m in range(N):\n C.append([int(i) for i in input().split()])\nC.sort(key=lambda x:x[0])\n\nfrom itertools import combinations\nimport numpy as np\n\n\nans = 10**5 +1\n\nfor m in range(1,N+1):\n P=list(combinations(C,m))\n print(P)\n tmp =np.sum(P,axis=1)\n for t in tmp:\n\n if min(t[1:])>=X and ans > t[0]:\n ans = t[0]\n\n \n \nif min(t[1:])<X:\n print(-1)\nelse:\n print(ans)', 'N,M,X =map(int,input().split())\nA =[]\nfor m in range(N):\n A.append([int(j) for j in input().split()])\nans = 10**10\nimport numpy as np\nfrom itertools import product,compress\nfor i in list(product([True,False],repeat=N)):\n tmp = np.sum(list(compress(A, i)),axis=0)\n if type(tmp)!=np.float64:\n \tif tmp[0]< ans and min(tmp[1:])>=X:\n ans =tmp[0]\nif ans ==10**10:\n print(-1)\nelse:\n print(ans)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s247880697', 's831417857', 's887469792', 's667109233'] | [28468.0, 28256.0, 28732.0, 27432.0] | [362.0, 128.0, 183.0, 169.0] | [480, 480, 464, 415] |
p02683 | u496511996 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\nimport copy\nn,m,x = map(int,input().split())\nans = [0 for i in range(m)]\nbooks = []\nanswer = 1000000000000000000000\nfor i in range(n):\n books.append(list(map(int,input().split())))\nfor i in range(n):\n stock = list(list(itertools.combinations([num for num in range(n)], i+1)))\n for j in stock:\n cost = 0\n ans = [0 for i in range(m)]\n for k in j:\n for e,l in enumerate(books[k]):\n if e == 0:\n cost += l\n else:\n ans[e-1] += l\n if min(ans) >= x and cost < answer:\n answer = copy.deepcopy(cost)\nif answer = 1000000000000000000000:\n print(-1)\nelse:\n print(answer)\n', 'import itertools\nimport copy\nn,m,x = map(int,input().split())\nans = [0 for i in range(m)]\nbooks = []\nanswer = 1000000000000000000000\nfor i in range(n):\n books.append(list(map(int,input().split())))\nfor i in range(n):\n stock = list(list(itertools.combinations([num for num in range(n)], i+1)))\n for j in stock:\n cost = 0\n ans = [0 for i in range(m)]\n for k in j:\n for e,l in enumerate(books[k]):\n if e == 0:\n cost += l\n else:\n ans[e-1] += l\n if min(ans) >= x and cost < answer:\n answer = copy.deepcopy(cost)\nif answer == 1000000000000000000000:\n print(-1)\nelse:\n print(answer)\n'] | ['Runtime Error', 'Accepted'] | ['s331599668', 's317518640'] | [9016.0, 9584.0] | [22.0, 91.0] | [716, 717] |
p02683 | u497277272 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['def Skill_Up():\n condition = input()\n condition_list = condition.split()\n N = int(condition_list[0])\n M = int(condition_list[1])\n X = int(condition_list[2])\n \n text_info=[]\n for i in range(0, N):\n text_book = input()\n text_info_str = text_book.split()\n text_book_int = []\n for j in text_info_str:\n text_book_int.append(int(j))\n text_info.append(text_book_int)\n \n text_effective = []\n for i in text_info:\n effective = 0\n for j in range(1, M+1):\n effective += i[j]\n effective /= i[0]\n text_effective.append(effective)\n \n for i in range(0, N):\n for j in range(0, N - i - 1):\n if text_effective[j] < text_effective[j+1]:\n text_effective[j], text_effective[j+1] = text_effective[j+1], text_effective[j]\n text_info[j], text_info[j+1] = text_info[j+1], text_info[j]\n \n skill_level = []\n skill_check = []\n for j in range(0, M+1):\n skill_level.append(0)\n skill_check.append(False)\n \n is_clear = False\n for i in range(0, N):\n for j in range(0, M+1):\n skill_level[j] += text_info[i][j]\n if skill_level[j] >= X:\n skill_check[j] = True\n for j in range(0, M+1):\n if skill_check[j] is False:\n is_clear = False\n break\n is_clear = True\n \n if is_clear:\n print(skill_level[0])\n else:\n print(-1)\n \nSkill_Up()', 'if __name__ == \'__main__\':\n n, m, x = list(map(int, input().split()))\n \n c = []\n a = []\n \n def calc_price(bit):\n price_total = 0\n learn_total = [0] * m \n \n for i in range(n):\n if (bit >> i) & 1:\n price_total += c[i]\n learn = a[i]\n for j, la in enumerate(learn):\n learn_total[j] += la\n \n if check(learn_total):\n return price_total\n else:\n return INF\n \n def check(learn_total):\n for i in range(m):\n if learn_total[i] < x:\n return False\n return True\n \n for i in range(n):\n c_temp, *a_temp = list(map(int, input().split()))\n c.append(c_temp)\n a.append(a_temp)\n \n INF = float("inf")\n ans = INF\n \n for bit in range(1 << n):\n price = calc_price(bit)\n ans = min(ans, price)\n \n if ans == INF:\n print(-1)\n else:\n print(ans)'] | ['Wrong Answer', 'Accepted'] | ['s236859558', 's800144930'] | [9228.0, 9144.0] | [25.0, 67.0] | [1524, 1020] |
p02683 | u497592162 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["n, m, x = map(int, input().split(' '))\ninput_lists = [list(map(int, input().split(' '))) for _ in range(n)]\n \ncomb = []\nfor i in range(2 ** n):\n tmp = []\n for j in range(n):\n if ((i >> j) & 1):\n tmp.append(input_lists[j])\n comb.append(tmp)\n\nresult = -1\nfor i in range(len(comb)):\n understand = [0]*m\n total_fee = 0\n for j in range(len(comb[i])):\n total_fee += comb[i][j][0]\n for k in range(1, m):\n understand[k] += comb[i][j][k]\n boolean = True\n for j in range(m):\n if all(t < x for t in understand):\n boolean = False\n if boolean and (result == -1 or result > understand[0]):\n result = total_fee\n \nprint(result)", "n, m, x = map(int, input().split(' '))\ninput_lists = [list(map(int, input().split(' '))) for _ in range(n)]\n \ncomb = []\nfor i in range(2 ** n):\n tmp = []\n for j in range(n):\n if ((i >> j) & 1):\n tmp.append(input_lists[j])\n comb.append(tmp)\n\nresult = -1\nfor i in range(len(comb)):\n understand = [0]*m\n total_fee = 0\n for j in range(len(comb[i])):\n total_fee += comb[i][j][0]\n for k in range(m):\n understand[k] += comb[i][j][k+1]\n if all(t >= x for t in understand) and (result == -1 or result > total_fee):\n result = total_fee\n \nprint(result)"] | ['Wrong Answer', 'Accepted'] | ['s566391089', 's563685618'] | [9488.0, 9236.0] | [121.0, 102.0] | [706, 612] |
p02683 | u500376440 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['N,M,X=map(int,input().split())\nCA=[list(map(int,input().split())) for _ in range(N)]\nprint(CA)\nmax_=10**16\nans=max_\nfor bit in range(2**N):\n check=[0]*M\n ans_=0\n for i in range(N):\n if bit>>i&1:\n ans_+=CA[i][0]\n for j in range(M):\n check[j]+=CA[i][j+1]\n if all([k>=X for k in check]):\n ans=min(ans,ans_)\nprint(ans if ans!=max_ else -1)\n', 'N,M,X=map(int,input().split())\nCA=[list(map(int,input().split())) for _ in range(N)]\nmax_=10**16\nans=max_\nfor bit in range(2**N):\n check=[0]*M\n ans_=0\n for i in range(N):\n if bit>>i&1:\n ans_+=CA[i][0]\n for j in range(M):\n check[j]+=CA[i][j+1]\n if all([k>=X for k in check]):\n ans=min(ans,ans_)\nprint(ans if ans!=max_ else -1)\n'] | ['Wrong Answer', 'Accepted'] | ['s774071830', 's522367299'] | [9216.0, 9196.0] | [99.0, 100.0] | [363, 353] |
p02683 | u500942659 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["import numpy as np\nimport itertools\nN, M, X = (int(i) for i in input().split())\nY = np.zeros((N, M+1))\nfor i in range(N):\n Y[i,:] = [int(i) for i in input().split()]\nC = Y[:,0]\nA = np.matrix(Y[:,1:])\nres = np.inf\nf = '0'+str(N)+'b'\nfor i in range(2**N):\n z = np.array([int(s) for s in list(format(i, f))])\n cost = z @ C\n skill = z * A\n if (skill >= X).all() and (cost < res):\n res = cost\nif np.isinf(res):\n print(-1)\nelse:\n print(res)", "import numpy as np\nimport itertools\nN, M, X = (int(i) for i in input().split())\nY = np.zeros((N, M+1))\nfor i in range(N):\n Y[i,:] = [int(i) for i in input().split()]\nC = Y[:,0]\nA = np.matrix(Y[:,1:])\nres = np.inf\nf = '0'+str(N)+'b'\nfor i in range(2**N):\n z = np.array([int(s) for s in list(format(i, f))])\n cost = z @ C\n skill = z * A\n if (skill >= X).all() and (cost < res):\n res = cost\nif np.isinf(res):\n print(-1)\nelse:\n print(int(res))"] | ['Wrong Answer', 'Accepted'] | ['s902576393', 's525161563'] | [27148.0, 27308.0] | [177.0, 178.0] | [462, 467] |
p02683 | u501064426 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["def solve(i, cost, know, x, a):\n global res\n if i == len(a):\n for j in range(m):\n if know[j] < x:\n return\n res = min(res, cost)\n return\n solve(i + 1, cost, know, x, a)\n for j in range(m):\n know[j] += a[i][j + 1]\n solve(i + 1, cost + a[i][0], know, x, a)\n for j in range(m):\n know[j] -= a[i][j + 1]\nfin = open('input.txt', 'r')\nn, m, x = [int(i) for i in input().split()]\na = [[int(i) for i in input().split()] for j in range(n)]\nknow = [0] * (m)\nres = 10 ** 7\nsolve(0, 0, know, x, a)\nprint(res if res != 10 ** 7 else - 1)", 'def solve(i, cost, know, x, a):\n global res\n if i == len(a):\n for j in range(m):\n if know[j] < x:\n return\n res = min(res, cost)\n return\n solve(i + 1, cost, know, x, a)\n for j in range(m):\n know[j] += a[i][j + 1]\n solve(i + 1, cost + a[i][0], know, x, a)\n for j in range(m):\n know[j] -= a[i][j + 1]\nn, m, x = [int(i) for i in input().split()]\na = [[int(i) for i in input().split()] for j in range(n)]\nknow = [0] * (m)\nres = 10 ** 7\nsolve(0, 0, know, x, a)\nprint(res if res != 10 ** 7 else - 1) '] | ['Runtime Error', 'Accepted'] | ['s866510884', 's890488248'] | [9112.0, 9232.0] | [21.0, 37.0] | [600, 572] |
p02683 | u502126017 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['A,B,C,K=(int(x) for x in input().split())\n\nif(K<=A+B):\n print(A)\nif(K>A+B):\n print(A-(K-A-B))', 'n,m,x=(int(i) for i in input().split())\na=[]\nc=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\n c.append(a[i][0])\n del a[i][0]\n \nINF=1001001001\nans=INF\n\nfor s in range(1<<n):\n cost=0\n d=[0]*m\n for i in range(n):\n if(s>>i&1):\n cost+=c[i]\n for j in range(m):\n d[j]+=a[i][j]\n ok=True\n for j in range(m):\n if(d[j]<x):\n ok=False\n if ok:\n ans=min(ans,cost)\nif ans==INF:\n print(-1)\nelse:\n print(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s737405624', 's091485808'] | [8976.0, 9200.0] | [22.0, 84.0] | [99, 452] |
p02683 | u517447467 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nimport itertools\nN, M, K = map(int, input().split())\nQ = [np.asarray(input().split(), dtype=int) for i in range(N)]\nmin_cost = 10**9\ndef dfs(cost, C, depth=0):\n global min_cost\n if depth == N:\n return\n if (C >= K).all():\n min_cost = min([cost, min_cost])\n return\n dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)\n dfs(cost, C, depth+1)\n \ndfs(0, np.zeros(M))\n \nprint(min_cost) if min_cost != 10**9 else print(-1)\n', 'import numpy as np\nimport itertools\nN, M, K = map(int, input().split())\nQ = [np.asarray(input().split(), dtype=int) for i in range(N)]\nmin_cost = 10**9\ndef dfs(cost, C, depth=0):\n global min_cost\n if (C >= K).all():\n min_cost = min([cost, min_cost])\n return\n if depth == N:\n return\n dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)\n dfs(cost, C, depth+1)\n \ndfs(0, np.zeros(M))\n \nprint(min_cost) if min_cost != 10**9 else print(-1)\n'] | ['Wrong Answer', 'Accepted'] | ['s812682625', 's250434646'] | [27232.0, 27240.0] | [116.0, 129.0] | [449, 449] |
p02683 | u517797706 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['if __name__ == \'__main__\':\n\n n,m,a = map(int,input().split())\n\n A = []\n for i in range(n):\n cmd = list(map(int,input().split()))\n A.append(cmd)\n print(A)\n\n \n INF = 10**19\n ans = INF\n for x in range(2**n):\n ALG = [0]*m\n gokei = 0\n for y in range(n):\n if (x>>y) & 1:\n #print(A[y])\n \n for j in range(m):\n ALG[j] += A[y][j+1]\n gokei += A[y][0]\n #print("ALG="+str(ALG))\n \n algflg=True\n for k in ALG:\n if k < a:\n algflg=False\n break\n if algflg:\n ans = min(ans,gokei)\n if ans == INF:\n print("-1")\n else:\n print(ans)\n', 'if __name__ == \'__main__\':\n\n n,m,a = map(int,input().split())\n\n A = []\n for i in range(n):\n cmd = list(map(int,input().split()))\n A.append(cmd)\n \n INF = 10**19\n ans = INF\n for x in range(2**n):\n ALG = [0]*m\n gokei = 0\n for y in range(n):\n if (x>>y) & 1:\n \n for j in range(m):\n ALG[j] += A[y][j+1]\n gokei += A[y][0]\n \n algflg=True\n for k in ALG:\n if k < a:\n algflg=False\n break\n if algflg:\n ans = min(ans,gokei)\n if ans == INF:\n print("-1")\n else:\n print(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s249663208', 's934994988'] | [9196.0, 9104.0] | [92.0, 92.0] | [977, 902] |
p02683 | u522293645 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x = map(int,input().split())\nli = [list(map(int,input().split())) for i in range(n)]\n\nans = 10**30\ncost = 0\nscore = [0]*m\n\nfor i in range(1<<(n+1)):\n for j in range(n):\n if (j>>i)&1:\n for k in range(m):\n score[k] += li[j][k+1]\n cost += li[j][0]\n if min(score)>=x:\n ans = min(ans,cost)\n score = [0]*m\n cost = 0\n\nif ans==10**30:\n print(-1)\nelse:\n print(ans)', 'n,m,x = map(int,input().split())\nli = [list(map(int,input().split())) for i in range(n)]\n\nans = 10**30\ncost = 0\nscore = [0]*m\n\nfor i in range(1<<(n+1)):\n for j in range(n):\n if (j>>i)&1:\n for k in range(m):\n score[k] += li[j][k+1]\n cost += li[j][0]\n print(cost,min(score))\n if min(score)>=x:\n ans = min(ans,cost)\n score = [0]*m\n cost = 0\n\nif ans==10**30:\n print(-1)\nelse:\n print(ans)', 'n,m,x = map(int,input().split())\nli = [list(map(int,input().split())) for i in range(n)]\n\nans = 10**30\ncost = 0\nscore = [0]*m\n\nfor i in range(1<<(n+1)):\n for j in range(n):\n # if (j>>i)&1:\n if i&(1<<j):\n for k in range(m):\n score[k] += li[j][k+1]\n cost += li[j][0]\n if min(score)>=x:\n ans = min(ans,cost)\n score = [0]*m\n cost = 0\n\nif ans==10**30:\n print(-1)\nelse:\n print(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s638868852', 's742947344', 's539591898'] | [9224.0, 9232.0, 9104.0] | [38.0, 33.0, 151.0] | [391, 420, 411] |
p02683 | u523087093 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['N, M, X = map(int, input().split())\n\nbook = [0]*N\n\nfor i in range(N):\n book[i] = list(map(int, input().split()))\n\nsorted_book = sorted(book)\n\nA_list = [0]*(M) \nfor j in range(1, M+1):\n A_sum = 0\n count = 0\n\n for i in range(N):\n A_sum += sorted_book[i][j]\n count +=1\n if A_sum >= X:\n break\n \n if A_sum < X:\n A_list[j -1] = -1\n else:\n A_list[j -1] = count\n\n\nanswer = 0\nif -1 in A_list:\n answer = -1\nelse:\n max_A_list = max(A_list)\n for i in range(max_A_list):\n answer += sorted_book[i][0]\n\nprint(A_list)\nprint(answer)\n', 'N, M, X = map(int, input().split())\n\nbook = [0]*N\n\nfor i in range(N):\n book[i] = list(map(int, input().split()))\n\nsorted_book = sorted(book)\n\nA_list = [0]*(M) \nfor j in range(1, M+1):\n A_sum = 0\n count = 0\n\n for i in range(N):\n A_sum += sorted_book[i][j]\n count +=1\n if A_sum >= X:\n break\n \n if A_sum < 10:\n A_list[j -1] = -1\n else:\n A_list[j -1] = count\n\n\nanswer = 0\nif -1 in A_list:\n answer = -1\nelse:\n max_A_list = max(A_list)\n for i in range(max_A_list):\n answer += sorted_book[i][0]\n\nprint(A_list)\nprint(answer)\n\n', 'import itertools\nimport numpy as np\n\nN, M, X = map(int, input().split())\n\nA = []\nC = []\nfor _ in range(N):\n temp_list = list(map(int, input().split()))\n A.append(temp_list[1:])\n C.append(temp_list[0])\n\nA = np.array(A)\nC = np.array(C)\n\nanswer = 10**9\nfor comb in itertools.product([0, 1], repeat= N):\n cost = 0\n A_memo = np.zeros(M, dtype=int)\n\n for i in range(N):\n if not comb[i]:\n continue\n\n A_memo += A[i]\n cost += C[i]\n\n if (A_memo >= X).sum() == M:\n answer = min(answer, cost)\n\nif answer == 10**9:\n print(-1)\nelse:\n print(answer)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s609551030', 's829796110', 's548555531'] | [9232.0, 9224.0, 27292.0] | [24.0, 26.0, 170.0] | [692, 694, 599] |
p02683 | u527379148 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nimport sys\nfrom itertools import product\n\nn, m, x = map(int, input().split())\nc = []\nA = []\n\nans = 10**9\n\nproducts = list(product([0,1], repeat=n))\n\nfor _ in range(n):\n c_a = list(map(int, input().split()))\n c.append(c_a[0])\n A.append(c_a[1:])\n\nmin_price = 10**9\n\nfor p in products:\n sum_alg = [0]*m\n price = 0\n for i, pp in enumerate(p):\n if pp == 1:\n for j in range(m):\n sum_alg[j] += A[i][j]\n price += c[i]\n\n if min(sum_alg) > x: \n min_price = min(price, min_price)\n\n\nif min_price == 10**9:\n print(-1)\nelse:\n print(min_price)\n\n\n\n', 'import numpy as np\nimport sys\nfrom itertools import product\n\nn, m, x = map(int, input().split())\nc = []\nA = []\n\nans = 10**9\n\nproducts = list(product([0,1], repeat=n))\n\nfor _ in range(n):\n c_a = list(map(int, input().split()))\n c.append(c_a[0])\n A.append(c_a[1:])\n\nmin_price = 10**9\n\nfor p in products:\n sum_alg = [0]*m\n price = 0\n for i, pp in enumerate(p):\n if pp == 1:\n for j in range(m):\n sum_alg[j] += A[i][j]\n price += c[i]\n\n if min(sum_alg) >= x: \n min_price = min(price, min_price)\n\n\nif min_price == 10**9:\n print(-1)\nelse:\n print(min_price)'] | ['Wrong Answer', 'Accepted'] | ['s367879455', 's802755254'] | [27396.0, 27396.0] | [159.0, 161.0] | [629, 626] |
p02683 | u528388170 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x=map(int,input().split())\n\nA=[[] for _ in range(n)] \nc=[0]*n \n\nfor i in range(n):\n c_as=list(map(int,input().split()))\n c[i],A[i]=c_as[0],c_as[1:]\n\nINF=10**9\nans=INF\n\nfor s in range(1<<n):\n smart=[0]*m\n cost_sum=0\n for i in range(n):\n if (s>>i)==0:\n continue\n cost_sum+=c[i]\n for j in range(m):\n smart[j]+=A[i][j]\n ok=True\n for j in range(m):\n if smart[j]<x:\n ok=False\n if ok:\n ans=min(ans,cost_sum)\nif ans==INF:\n ans=-1\n\nprint(ans)', 'n,m,x=map(int,input().split())\n\nA=[[] for _ in range(n)] \nc=[0]*n \n\nfor i in range(n):\n c_as=list(map(int,input().split()))\n c[i],A[i]=c_as[0],c_as[1:]\n\nINF=10**9\nans=INF\n\nfor s in range(0,1<<n):\n smart=[0]*m\n cost_sum=0\n for i in range(n):\n if (s>>i)%2==0:\n continue\n cost_sum+=c[i]\n for j in range(m):\n smart[j]+=A[i][j]#\n ok=True\n for j in range(m):\n if smart[j]<x:\n ok=False\n if ok:\n ans=min(ans,cost_sum)\nif ans==INF:\n ans=-1\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s788459642', 's975316262'] | [9144.0, 9092.0] | [127.0, 84.0] | [561, 610] |
p02683 | u531599639 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['def cos_per_find(count, cost, skills):\n if count == N:\n if min(skills) >= X:\n return cost\n else:\n return INF\n improved_skills = [a+b for a, b in zip(skills, contents[count])]\n return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))\n\nINF = float(inf)\nN, M, X = map(int, input().split())\nprice = []\ncontents = []\nfor i in range(N):\n C, *A = map(int, input().split())\n price.append(C)\n contents.append(A)\nans = cos_per_find(0, 0, [0]*M)\nif ans == INF:\n print(-1)\nelse:\n print(ans)', 'def cos_per_find(count, cost, skills):\n if count == N:\n if min(skills) >= X:\n return cost\n else:\n return INF\n improved_skills = [a+b for a, b in zip(skills, contents[count])]\n return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))\n\nINF = float(inf)\nN, M, X = map(int, input().split())\nprice = []\ncontents = []\nfor i in range(N):\n C, *A = map(int, input().split())\n price.append(C)\n contents.append(A)\nif (ans := cos_per_find(0, 0, [0]*M)) == INF:\n print(-1)\nelse:\n print(ans)', 'def cos_per_find(count, cost, skills):\n if count == N:\n if min(skills) >= X:\n return cost\n else:\n return INF\n improved_skills = [a+b for a, b in zip(skills, contents[count])]\n return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))\n\nINF = float(inf)\nN, M, X = map(int, input().split())\nprice = []\ncontents = []\nfor i in range(N):\n C, *A = map(int, input().split())\n price.append(C)\n contents.append(A)\nif ans(:=cos_per_find(0, 0, [0]*M))== INF:\n print(-1)\nelse:\n print(ans)', "N, M, X = map(int, input().split())\ncost = []\ncont = []\nINF = float('inf')\nfor _ in range(N):\n C, *A = map(int, input().split())\n cost.append(C)\n cont.append(A)\n \ndef calc(bit):\n price = 0\n skill = [0]*M\n for i in range(N):\n if (bit >> i) & 1:\n price += cost[i]\n for j, la in enumerate(cont[i]):\n skill[j] += la\n if min(skill) >= X:\n return price\n else:\n return INF\n \nans = INF\nfor bit in range(1 << N):\n price = calc(bit)\n ans = min(ans, price)\nif ans == INF:\n print(-1)\nelse:\n print(ans)"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s554103734', 's711792724', 's933822274', 's128726698'] | [9076.0, 9132.0, 9076.0, 9240.0] | [25.0, 23.0, 20.0, 55.0] | [588, 587, 584, 589] |
p02683 | u536034761 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['N, M, X = map(int, input().split())\nbooks = [input() for i in range(N)]\nresult = 12 * 10**5 + 1\nfor i in range(1, 1 << N):\n skill = [0 for i in range(N)]\n for j in range(N):\n if (i >> j) & 1:\n book = books[j].split()\n cost += int(book[0])\n for k in range(M):\n skill[k] += int(book[k + 1])\n if all(j >= X for j in skill):\n result = min(result, cost)\nif result == 12 * 10**5 + 1:\n print(-1)\nelse:\n print(result)', 'N, M, X = map(int, input().split())\nbook_information = []\nresult = 12 * 10**5\nfor i in range(N):\n\tbook_information.append(input())\nfor i in range(1, 1 << N):\n bought_book = []\n n = 0\n skill = [0 for j in range(M)]\n for j in range(N):\n if (i >> j) & 1:\n bought_book.append(book_information[j - 1])\n n += 1\n for j in range(n - 1):\n bought_book_information = list(map(bought_book[j].split(" ")))\n cost += bought_book_information[0]\n for k in range(M):\n skill[k] += bought_book_information[k + 1]\n if all(x >= X for x in skill):\n result = min(result, cost)\nif result == 12 * 10**5:\n print(-1)\nelse:\n print(result)', 'N, M, X = map(int, input().split())\nbooks = [input() for i in range(N)]\nresult = 12 * 10**5 + 1\nfor i in range(1, 1 << N):\n cost = 0\n skill = [0 for i in range(M)]\n for j in range(N):\n if (i >> j) & 1:\n book = books[j].split()\n cost += int(book[0])\n for k in range(M):\n skill[k] += int(book[k + 1])\n if all(j >= X for j in skill):\n result = min(result, cost)\nif result == 12 * 10**5 + 1:\n print(-1)\nelse:\n print(result)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s132728014', 's755371196', 's690899238'] | [9036.0, 9248.0, 9064.0] | [22.0, 22.0, 141.0] | [442, 647, 453] |
p02683 | u536642030 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x = list(map(int, input().split()))\nbook = []\nfor i in range(n):\n book.append(list(map(int, input().split())))\nans = 10 ** 5 * n\nfor i in product([0,1], repeat=n):\n price = 0\n skill = [0] * m\n for index_, bit in enumerate(i):\n if bit:\n for j in range(m):\n skill[j] += book[index_][ j + 1]\n price += book[index_][0]\n if all(v >= x for v in skill):\n ans = min(ans, price)\n \nprint(ans)', 'from itertools import product\n\nn,m,x = list(map(int, input().split()))\nbook = []\nfor i in range(n):\n book.append(list(map(int, input().split())))\n\nans = 10 ** 5 * n\nflag = False\nfor i in product([0,1], repeat=n):\n price = 0\n skill = [0] * m\n for index_, bit in enumerate(i):\n if bit:\n for j in range(m):\n skill[j] += book[index_][ j + 1]\n price += book[index_][0]\n if all(v >= x for v in skill):\n ans = min(ans, price)\n flag = True\nif flag:\n print(ans)\nelse:\n print(-1)'] | ['Runtime Error', 'Accepted'] | ['s222871733', 's318984810'] | [9224.0, 9216.0] | [25.0, 91.0] | [423, 548] |
p02683 | u537142137 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\n\nN, M, X = map(int, input().split())\n\nca = []\nfor _ in range(N):\n ca.append( list(map(int, input().split())))\nca.sort(key=lambda x:-x[0])\nca = np.array(ca)\n#\nans = 10000000\nskill = [0]*(M+1)\n\n\ndef DFS(n,skill):\n global ans\n if skill[0] >= ans:\n return\n if min(skill[1:]) >= X:\n ans = min(ans, skill[0])\n return\n if n >= N:\n return\n DFS(n+1,skill)\n skill = skill + ca[n]\n DFS(n+1,s)\n skill = skill - ca[n]\n return\n#\n\nDFS(0,skill)\nif ans == 10000000:\n print(-1)\nelse:\n print(ans)\n#', 'import numpy as np\n\nN, M, X = map(int, input().split())\n\nca = []\nfor _ in range(N):\n ca.append( list(map(int, input().split())))\nca.sort(key=lambda x:x[0])\nca = np.array(ca)\n#\nans = 10000000\nskill = [0]*(M+1)\n\n\ndef DFS(n):\n global ans,skill\n if skill[0] >= ans:\n return\n if min(skill[1:]) >= X:\n ans = min(ans, skill[0])\n return\n if n >= N:\n return\n skill = skill + ca[n]\n DFS(n+1)\n skill = skill - ca[n]\n DFS(n+1)\n return\n#\n\nDFS(0)\nif ans == 10000000:\n print(-1)\nelse:\n print(ans)\n#'] | ['Runtime Error', 'Accepted'] | ['s466849538', 's963553989'] | [27236.0, 27176.0] | [109.0, 128.0] | [522, 507] |
p02683 | u537550206 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["n, m, x = map(int, input().split())\nbooks = []\nbook_total_price = []\nfor _ in range(n):\n book = list(map(int, input().split()))\n books.append(book)\n\nfor i in range(n**2 - 1):\n reference_book = []\n book_price = 0\n for j in range(n):\n if (i >> j) & 1:\n reference_book.append(books[j])\n book_price += books[j][0]\n print(reference_book)\n err = 0\n for k in range(1, m+1):\n r = [row[k] for row in reference_book]\n if sum(r) < x:\n err += 1\n if err == 0:\n book_total_price.append(book_price)\nif book_total_price == []:\n print('-1')\nelse:\n print(min(book_total_price))", "n, m, x = map(int, input().split())\nbooks = []\nbook_total_price = []\nfor _ in range(n):\n book = list(map(int, input().split()))\n books.append(book)\n \nfor i in range(2**n):\n reference_book = []\n book_price = 0\n for j in range(n):\n if (i >> j) & 1:\n reference_book.append(books[j])\n book_price += books[j][0]\n err = 0\n for k in range(1, m+1):\n r = [row[k] for row in reference_book]\n if sum(r) < x:\n err += 1\n if err == 0:\n book_total_price.append(book_price)\nif book_total_price == []:\n print('-1')\nelse:\n print(min(book_total_price))"] | ['Wrong Answer', 'Accepted'] | ['s854603470', 's448160939'] | [9252.0, 9316.0] | [26.0, 60.0] | [653, 624] |
p02683 | u548545174 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nN, M, X = map(int, input().split())\nprices = []\neffects = []\nfor i in range(N):\n c, *a = map(int, input().split())\n prices.append(c)\n effects.append(list(a))\n\nprices = np.array(prices)\neffects = np.array(effects)\n\n\nans = float("inf")\n\npats = []\nfor i in range(2 ** N):\n pat = bin(i).replace("0b", "")\n pat += "0" * (N - len(pat))\n pat = list(map(int, list(pat)))\n pats.append(pat)\n \npats = np.array(pats)\ntotal_price = np.dot(pats, prices)\ntotal_effects = np.dot(pats, effects)\ncond = ((total_effects >= X).sum(axis=1) == M)\n\n\nans = int(total_price[cond == 1].min())\nprint(ans)', '\nimport numpy as np\nN, M, X = map(int, input().split())\ndata = np.array([list(map(int, input().split())) for i in range(N)], dtype=np.int64)\n\nprices = data[:, 0]\neffects = data[:, 1:]\n \nans_cands = []\n\nfor i in range(2 ** N):\n cur_costs = []\n cur_effects = np.zeros(M)\n \n for j in range(N):\n if (i >> j) & 1:\n cur_costs.append(prices[j])\n cur_effects += effects[j, :]\n\n if np.all(cur_effects >= X):\n ans_cands.append(sum(cur_costs))\n\nans = min(ans_cands) if len(ans_cands) > 0 else -1\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s402210205', 's805650627'] | [28272.0, 27308.0] | [136.0, 203.0] | [620, 633] |
p02683 | u551109821 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['from itertools import product\nN,M,X = map(int,input().split())\nca = [list(map(int,input().split())) for _ in range(N)]\nfor i in range(1,M+1):\n count=0\n for j in range(N):\n count+=ca[j][i]\n if count<X:\n print(-1)\n exit()\n\nans = 10**9\nfor z in product((0, 1), repeat=N):\n count=0\n count2=[0]*M\n for i in range(N):\n if z[i]==1:\n count+=ca[i][0]\n for j in range(1,M+1):\n count2[j-1]+=ca[i][j]\n \n for i in range(m):\n if count2[i]<x:\n break\n else:\n ans=min(count,ans)\nprint(ans)\n', 'N,M,X = map(int,input().split())\nC = []\nA = []\nsuccess = []\n\nfor i in range(N):\n Z = list(map(int,input().split()))\n C.append([Z[0],i])\n A.append(Z[1:])\n\nC.sort()\nn = len(C)\nitems = []\nfor i in range(2 ** n):\n item = []\n for j in range(n): \n if ((i >> j) & 1): \n item.append(C[j]) \n items.append(item)\n\nprint(items)\nfor i in range(1,len(items)):\n sum = 0\n a1 = 0\n a2 = 0\n a3 = 0\n for j in range(len(items[i])):\n index = items[i][j][1]\n a1 += A[index][0]\n a2 += A[index][1]\n a3 += A[index][2]\n sum += items[i][j][0]\n if a1 >= X and a2 >= X and a3 >= X:\n success.append(sum)\nif len(success) == 0:\n print(-1)\nelse:\n print(min(success))', 'from itertools import product\nN,M,X = map(int,input().split())\nca = [list(map(int,input().split())) for _ in range(N)]\nfor i in range(1,M+1):\n count=0\n for j in range(N):\n count+=ca[j][i]\n if count<X:\n print(-1)\n exit()\n\nans = []\nfor z in product((0, 1), repeat=N):\n count=0\n count2=[0]*M\n for i in range(N):\n if z[i]==1:\n count+=ca[i][0]\n for j in range(1,M+1):\n count2[j-1]+=ca[i][j]\n \n for i in range(M):\n if count2[i]<X:\n break\n else:\n ans.append(count)\nprint(min(ans))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s120136818', 's776833768', 's994381039'] | [9176.0, 10200.0, 9320.0] | [24.0, 55.0, 88.0] | [673, 901, 674] |
p02683 | u553600587 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['from itertools import product\n\nN, M, X = [int(x) for x in input().strip().split(" ")]\nC = []\nA = []\n\nfor _ in range(N):\n v = [int(x) for x in input().strip().split(" ")]\n c = v.pop(0)\n C.append(c)\n A.append(v)\n\nsums = []\npatterns = product(*[(0, 1) for _ in range(N)])\nfor pattern in patterns:\n price = 0\n print(pattern)\n status = [0 for _ in range(M)]\n for i, p in enumerate(pattern):\n price += C[i] * p\n for j in range(M):\n status[j] += A[i][j] * p\n if min(status) >= X:\n sums.append(price)\n\nif len(sums) > 0:\n print(min(sums))\nelse:\n print(-1)', 'from itertools import product\n\nN, M, X = [int(x) for x in input().strip().split(" ")]\nC = []\nA = []\n\nfor _ in range(N):\n v = [int(x) for x in input().strip().split(" ")]\n c = v.pop(0)\n C.append(c)\n A.append(v)\n\nsums = []\npatterns = product(*[(0, 1) for _ in range(N)])\nfor pattern in patterns:\n price = 0\n status = [0 for _ in range(M)]\n for i, p in enumerate(pattern):\n price += C[i] * p\n for j in range(M):\n status[j] += A[i][j] * p\n if min(status) >= X:\n sums.append(price)\n\nif len(sums) > 0:\n print(min(sums))\nelse:\n print(-1)'] | ['Wrong Answer', 'Accepted'] | ['s997779315', 's129656278'] | [9200.0, 9340.0] | [144.0, 143.0] | [611, 592] |
p02683 | u554096168 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\n\nN, M, X = map(int, input().split())\n\nC = [0] * N\nA = [list() for _ in range(N)]\n\nfor i in range(N):\n C[i], *A[i] = map(int, input().split())\n\nans = sum(C)\n\nb = False\nfor i in range(1, N+1):\n for j in itertools.combinations(range(N), i):\n print(j)\n a = [0] * M\n for k in j:\n for l in range(M):\n a[l] += A[k][l]\n print("a ", a)\n for aa in a:\n if aa < X:\n break\n else:\n ans = min(ans, sum(C[k] for k in j))\n print(ans, "!!!")\n b = True\n if b:\n break\n\nif not b:\n print(-1)\nelse:\n print(ans)\n', '(N, M, X), *T = [[*map(int, line.split())] for line in open(0)]\n\nans = 12345678\nfor bit in range(1, 2**N):\n t = [T[i] for i in range(N) if bit & (1 << i)]\n c, *a = map(sum, zip(*t))\n if all(e >= X for e in a):\n ans = min(ans, c)\n\nprint(-1 if ans == 12345678 else ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s815384148', 's134861809'] | [9252.0, 9204.0] | [79.0, 40.0] | [654, 284] |
p02683 | u556594202 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['N,M,X = list(map(int,input().split()))\nskill = [list(map(int,input().split())) for i in range(N)]\ncost = []\n\nfor i in range(2**N):\n total_skill=[0,0,0,0]\n for j in range(N):\n if ((i>>j) & 1):\n total_skill = [x+y for (x,y) in zip(total_skill,skill[j])]\n count=0\n print(i,"回目")\n print(total_skill)\n for k in total_skill[1:]:\n print(k)\n if k<X:\n count +=1\n if count==0:\n cost.append(total_skill[0])\n\ncost.sort()\nprint(-1 if cost==[] else cost[0])\n', 'import numpy as np\n\nN,M,X = map(int,input().split())\nca=np.array([0]*(M+1))\nans = 10**7\n\nfor i in range(N):\n ca=np.vstack([ca,[int(i) for i in input().split()]])\n\nfor i in range(2**N):\n\n need_skills=np.array([0]+[X]*M)\n\n buy_item = [0]*N\n for j in range(N):\n if (i>>j)&1:\n buy_item[j]=1\n\n print("buy_item",buy_item)\n for k in range(N):\n need_skills -= ca[k+1]*buy_item[k]\n\n print(need_skills)\n if np.all(need_skills<=0):\n ans = min(ans,-need_skills[0])\n\nprint(-1 if ans==10**7 else ans)', 'import numpy as np\n\nN,M,X = map(int,input().split())\nca=np.array([0]*(M+1))\nans = 10**7\n\nfor i in range(N):\n ca=np.vstack([ca,[int(i) for i in input().split()]])\n\nfor i in range(2**N):\n\n need_skills=np.array([0]+[X]*M)\n\n buy_item = [0]*N\n for j in range(N):\n if (i>>j)&1:\n buy_item[j]=1\n\n for k in range(N):\n need_skills -= ca[k+1]*buy_item[k]\n\n if np.all(need_skills<=0):\n ans = min(ans,-need_skills[0])\n\nprint(-1 if ans==10**7 else ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s451818996', 's602562756', 's902401355'] | [9272.0, 27412.0, 27380.0] | [64.0, 441.0, 238.0] | [519, 542, 489] |
p02683 | u559250296 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import numpy as np\nS= input().split()\nn=int(S[0])\nm=int(S[1])\nx=int(S[2])\na=[m+1]\nbook = np.zeros((m+1,n))\ntotal = np.zeros(m+1)\n\nfor i in range(n):\n a=list(map(int,input().split()))\n for k in range(m+1):\n book[k][i] = a[k]\n\ntotal = np.sum(book, axis=1)\nans =total.copy()\nb = total.copy()\n\nfor l in range(n):\n b = ans.copy()\n for j in range(m):\n b[j+1] -= book[j+1][l]\n if b[j+1] < x:\n break\n if j ==m -1:\n b[0] -= book[0][l]\n ans = b.copy()\nprint(ans[0])\n\n\n\n\n\n\n', 'import itertools\nn,m,x =map(int,input().split())\nlists=[]\nunderstand=[0]*m\nnum= [0,1]\nans = 10**10000\npatterns = list(itertools.product(num, repeat=n))\nfor i in range(n):\n lists.append(list(map(int,input().split())))\ntotal =0\n\nfor i in patterns:\n pattern = list(i)\n total =0\n understand=[0]*m\n for l in range(n):\n if pattern[l] ==1:\n total += lists[l][0]\n for k in range(m):\n understand[k] += lists[l][k+1]\n understand.sort()\n if understand[0] >= x:\n ans = min(ans,total)\nif ans == 10**10000:\n print(-1)\nelse:\n print(ans)\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s881258678', 's267538621'] | [27216.0, 9544.0] | [112.0, 91.0] | [536, 630] |
p02683 | u563838154 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['n,m,x = map(int,input().split())\nbook = [list(map(int, input().split())) for _ in range(n)]\ncos_min=10**10\nfor i in range(1,2**n):\n s_c= [0]*(m+1)\n choose = bin(i).zfill(n)\n\n for j in range(n):\n if choose[n-j-1]=="1": \n s_c = [a+b for (a,b)in zip(s_c,book[j])]\n\n for j in s_c[1:]:\n if j<x:\n break\n else:\n cos_min=min(cos_min,s_c[0])\n\nif cos_min!=10**10 :\n print(cos_min)\nelse:\n print(-1) ', 'n,m,x = map(int,input().split())\nbook = [list(map(int, input().split())) for _ in range(n)]\ncos_min=10**10*n\nfor i in range(1,2**n):\n s_c= [0]*(m+1)\n choose = bin(i)[2:].zfill(n)\n\n for j in range(n):\n if choose[n-j-1]=="1": \n s_c = [a+b for (a,b)in zip(s_c,book[j])]\n\n for j in s_c[1:]:\n if j<x:\n break\n else:\n cos_min=min(cos_min,s_c[0])\n\nif cos_min!=10**10*n :\n print(cos_min)\nelse:\n print(-1) \n'] | ['Wrong Answer', 'Accepted'] | ['s869365029', 's238452940'] | [9236.0, 9168.0] | [54.0, 58.0] | [455, 465] |
p02683 | u564770050 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ['import itertools\n\nn,m,x = map(int,input().split())\n\nans = 0\ntmp = 10 ** 7\nca = [[0]*m for i in range(n)]\n\nfor _ in range(n):\n ca[_] = list(map(int, input().split()))\nprint(ca)\n\nxx = list(itertools.permutations(ca))\n\n\nfor cax in xx:\n ans = 0\n a = [0 for i in range(m)]\n\n for _ in range(n):\n cost = cax[_][0]\n chk = 0\n for i in range(m):\n a[i] += cax[_][i+1]\n if a[i] < x:\n chk = 1\n\n ans += cost\n if chk == 0:\n if tmp > ans:\n tmp = ans\n break\nif tmp == 10 ** 7:\n print(-1)\n exit()\nprint(tmp)', 'def main():\n n,m,x = map(int,input().split())\n a = [[] for _ in range(n)]\n c = [0] * n\n\n INF = 10 ** 9\n ans = INF\n\n for i in range(n):\n ca = list(map(int,input().split()))\n c[i],a[i] = ca[0],ca[1:]\n\n for s in range(0,1<<n):\n smart = [0] * m\n cost = 0\n for i in range(n):\n if(s>>i) % 2 == 0:continue\n cost += c[i]\n for j in range(m):\n smart[j] += a[i][j]\n ok = True\n for i in range(m):\n if smart[i] < x:\n ok = False\n if ok:\n ans = min(ans,cost)\n if ans == INF:\n ans = -1\n \n print(ans)\n\nif __name__ == "__main__":\n main()\n\n\n '] | ['Wrong Answer', 'Accepted'] | ['s180910578', 's031102930'] | [361784.0, 9212.0] | [2218.0, 71.0] | [643, 718] |
p02683 | u574464625 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["#Skill Up\nn,m,x = map(int, input().split())\n\n#ca = [map(int, input().split()) for _ in range(n)]\n#ca = [input().split() for l in range(n)]\nimport sys\nca = [[int(c) for c in l.split()] for l in sys.stdin]\n\n#print(ca)\n#print(ca[0][0])\nc=[]\na=[]\nfor l in range(n):\n c.append(ca[l][0])\n#print(c)\n\nfor l in range(n):\n del ca[l][0]\n#print(ca)\na=ca\n\nINF = float('INF')\nmin_cost = INF\n \ndef dfs(i, cost, learn):\n if i == n:\n if min(learn) >= x:\n return cost\n else:\n return INF\n else:\n new_learn = [X + Y for (X, Y) in zip(a[i], learn)]\n cost = min(dfs(i + 1, cost, learn), dfs(i + 1, cost + C[i], new_learn))\n return cost\n \nmin_cost = dfs(0, 0, [0] * m)\n \nif min_cost == INF:\n print(-1)\nelse:\n print(min_cost)\n\n\n", "#Skill Up\nn,m,x = map(int, input().split())\n\n#ca = [map(int, input().split()) for _ in range(n)]\n#ca = [input().split() for l in range(n)]\nimport sys\nca = [[int(c) for c in l.split()] for l in sys.stdin]\n\n#print(ca)\n#print(ca[0][0])\nc=[]\nfor l in range(n):\n c.append(ca[l][0])\n#print(c)\n\nfor l in range(n):\n del ca[l][0]\n#print(ca)\n\nINF = float('INF')\nmin_cost = INF\n \ndef dfs(i, cost, learn):\n if i == n:\n if min(learn) >= x:\n return cost\n else:\n return INF\n else:\n new_learn = [X + Y for (X, Y) in zip(ca[i], learn)]\n cost = min(dfs(i + 1, cost, learn), dfs(i + 1, cost + c[i], new_learn))\n return cost\n \nmin_cost = dfs(0, 0, [0] * m)\n \nif min_cost == INF:\n print(-1)\nelse:\n print(min_cost)"] | ['Runtime Error', 'Accepted'] | ['s009736873', 's544112606'] | [9252.0, 9244.0] | [26.0, 28.0] | [814, 802] |
p02683 | u580920947 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms. Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it. | ["#!/usr/bin/env python\n\ndef main():\n N, M, X = map(int, input().split())\n mat = [list(map(int, input().split())) for _ in range(N)]\n\n ans = 12 * (10 ** 5) +1\n for i in range(1<<N):\n tmp = [0] * (M+1)\n for j in range(N):\n if (i>>j)&1:\n tmp = [x+y for x, y in zip(tmp, mat[j])]\n flag = True\n for i in range(1, M):\n if tmp[i] < X:\n break\n ans = min(ans, tmp[0])\n\n print('-1') if ans == 12 * (10 ** 5) +1 else print(ans)\n \nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python\n\ndef main():\n N, M, X = map(int, input().split())\n mat = [list(map(int, input().split())) for _ in range(N)]\n\n ans = 12 * (10 ** 5) +1\n for i in range(1<<N):\n tmp = [0] * (M+1)\n for j in range(N):\n if (i>>j)&1:\n tmp = [x+y for x, y in zip(tmp, mat[j])]\n if all(tmp[i] >= X for i in range(1, M):\n ans = min(ans, tmp[0])\n\n print('-1') if ans == 12 * (10 ** 5) +1 else print(ans)\n \nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python\n\ndef main():\n N, M, X = map(int, input().split())\n mat = [list(map(int, input().split())) for _ in range(N)]\n\n flag = False\n ans = 10 ** 18\n\n for i in range(1<<N):\n tmp = [0] * (M+1)\n mflag = True\n for j in range(N):\n if (i>>j)&1:\n tmp = [x+y for x, y in zip(tmp, mat[j])]\n for k in range(M):\n if tmp[1+k] < X:\n mflag = False\n break\n if mflag and tmp[0] < ans:\n ans = tmp[0]\n flag = True\n print(ans) if flag else print('-1')\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s494222859', 's560499222', 's217242480'] | [9220.0, 8856.0, 9224.0] | [62.0, 25.0, 62.0] | [569, 527, 628] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.