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
u581603131
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 i in range(N)]\n\nA = [0]*M\nfor i in range(N):\n for k in range(M):\n A[k] += CA[i][k+1]\nfor i in range(M):\n if A[i] < X:\n print('-1')\n exit() \n\nprice = 0\nans = 10**10\nA = [0]*M\nfor i in range(2**N):\n list = [1]*N\n for j in range(len(list)):\n if (i>>j) & 1:\n list[j] = 0\n for k in range(N):\n if list[k] == 1:\n for s in range(M):\n A[s] += CA[k][s+1]\n price += CA[k][0]\n if all(A[m] >= X for m in range(M)):\n ans = min(ans,price)\n price = 0\nprint(ans)", "N, M, X = map(int, input().split())\nCA = [list(map(int, input().split())) for i in range(N)]\n\nA = [0]*M\nfor i in range(N):\n for k in range(M):\n A[k] += CA[i][k+1]\nfor i in range(M):\n if A[i] < X:\n print('-1')\n exit() \n\nA = [0]*M\nprice = 0\nCA.sort(key=lambda CA:(CA[0]))\nfor i in range(N):\n for k in range(M):\n A[k] += CA[i][k+1]\n price += CA[i][0]\n if all(A[l] >= X for l in range(M)):\n print(price)\n break", "N, M, X = map(int, input().split())\nCA = [list(map(int, input().split())) for i in range(N)]\n\nA = [0]*M\nfor i in range(N):\n for k in range(M):\n A[k] += CA[i][k+1]\nfor i in range(M):\n if A[i] < X:\n print('-1')\n exit() \n\nprice = 0\nans = 10**10\nA = [0]*M\nfor i in range(2**N):\n list = [1]*N\n for j in range(len(list)):\n if (i>>j) & 1:\n list[j] = 0\n price = 0\n A = [0]*M\n for k in range(N):\n if list[k] == 1:\n for s in range(M):\n A[s] += CA[k][s+1]\n price += CA[k][0]\n if all(A[m] >= X for m in range(M)):\n ans = min(ans,price)\nprint(ans)"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s856711915', 's944196768', 's414190805']
[9188.0, 9236.0, 9236.0]
[21.0, 22.0, 1161.0]
[626, 467, 676]
p02683
u601620345
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())\n\n\nCA = np.zeros((n,m+1))\n\nfor i in range(n):\n CA[i]=list(map(int, input().split()))\n # C[i],A[i]=T[0],T[1:]\n#print(A,C)\n\nmin_cost = 9999999999999999\n\nfor i in range(2**n):\n T = np.zeros((m+1))\n for j in range(n):\n if i&(2**j) > 0:\n T += CA[j]\n if all(T[1:] >= x):\n min_cost = min(min_cost,T[0]) \n\nprint(min_cost)', 'import numpy as np\nn,m,x = map(int, input().split())\n\n\nCA = np.zeros((n,m+1))\n\nfor i in range(n):\n CA[i]=list(map(int, input().split()))\n # C[i],A[i]=T[0],T[1:]\n#print(A,C)\n\nmin_cost = -1\n\nfor i in range(2**n):\n T = np.zeros((m+1))\n for j in range(n):\n if i&(2**j) > 0:\n T += CA[j]\n if all(T[1:] >= x):\n if min_cost == -1:\n min_cost = T[0]\n else: \n min_cost = min(min_cost,T[0]) \n\nprint(int(min_cost))']
['Wrong Answer', 'Accepted']
['s212167537', 's889082101']
[27116.0, 27188.0]
[165.0, 158.0]
[433, 498]
p02683
u607569985
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\nbook=[]\nskil=[0]*M\nfor i in range(N):\n line=list(map(int,input().split(\' \')))\n book.append(line)\n skil=list(map(lambda x,y:x+y,skil,line[1:]))\n\nmin_p=1200000\nfor n in range(1,N+1):\n for conbo in itertools.combinations(book,n):\n conbo_book=[0]*(1+M)\n for b in list(conbo):\n conbo_book=list(map(lambda x,y:x+y,conbo_book,b))\n if len([m for m in conbo_book[1:] if m>=X])==M:\n print(conbo_book)\n if min_p>conbo_book[0]:\n min_p=conbo_book[0]\n\nprint(min_p) if min_p<1200000 else print("-1")', 'import itertools\n\nN,M,X=map(int,input().split(\' \'))\n\nbook=[]\nskil=[0]*M\nfor i in range(N):\n line=list(map(int,input().split(\' \')))\n book.append(line)\n skil=list(map(lambda x,y:x+y,skil,line[1:]))\n\nmin_p=12000000\nfor n in range(1,N+1):\n for conbo in itertools.combinations(book,n):\n conbo_book=[0]*(1+M)\n for b in list(conbo):\n conbo_book=list(map(lambda x,y:x+y,conbo_book,b))\n if len([m for m in conbo_book[1:] if m>=X])==M:\n if min_p>conbo_book[0]:\n min_p=conbo_book[0]\n\nprint(min_p) if min_p<12000000 else print("-1")']
['Wrong Answer', 'Accepted']
['s803103634', 's657998592']
[9284.0, 9248.0]
[64.0, 61.0]
[618, 590]
p02683
u608007704
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=[]\nmaxNum=999999999\ndmaxNum=999999999\nfor i in range(N):\n C.append(map(int, input().split(' ')))\n\nfor i in range(2**(N+1)-1):\n ar=[]\n for i in range(M):\n if (i & 2**i) == 0:\n ar = [x * y for (x, y) in zip(ar, C[i])]\n print(ar)\n for i in ar:\n if i < X:\n break\n", "import numpy as np\n\nN,M,X = map(int, input().split(' '))\nC=[]\nmaxNum=999999999\ndmaxNum=999999999\nfor i in range(N):\n C.append(list(map(int, input().split(' '))))\nfor i in range(2**N):\n ar=[0]*(M+1)\n for j in range(N):\n if (i & 2**j) != 0:\n ar = [x + y for (x, y) in zip(ar, C[j])]\n if (np.array(ar[1:])>=X).all()>0:\n maxNum=min(maxNum,ar[0])\nif maxNum==dmaxNum:\n print(-1)\nelse:\n print(maxNum)"]
['Runtime Error', 'Accepted']
['s049291322', 's093221417']
[9204.0, 27324.0]
[83.0, 169.0]
[319, 410]
p02683
u608178601
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\n\nN,M,X=map(int, input().split())\nlist_=[list(map(int, input().split())) for _ in range(N)]\ngokei=X\ncost=100001\nlist_C=[]\n\nfor i in range(N):\n\tlist_C=np.array(list(combinations(list_,N-i)))\n\tcount=0\n\tfor h in range(len(list_C)):\n\n\t\tif all(np.sum(list_C[h], axis=0)[1:]>=X) and np.sum(list_C[h], axis=0)[0]<cost:\n\t\t\t\tcost=np.sum(list_C[h], axis=0)[0]\n\t\t\t\tcount+=1\n\n\t\tif count==0:\n\t\tbreak\n\nprint(cost if cost<100001 else -1)\n', 'from itertools import combinations\nimport numpy as np\n\nN,M,X=map(int, input().split())\nlist_=[list(map(int, input().split())) for _ in range(N)]\ncost=100000001\nlist_C=[]\n\nfor i in range(N):\n\tlist_C=np.array(list(combinations(list_,N-i)))\n\tcount=0\n\t#print(list_C)\n\tfor h in range(len(list_C)):\n\t\tif all(np.sum(list_C[h], axis=0)[1:]>=X):\n\t\t\tif np.sum(list_C[h], axis=0)[0]<cost:\n\t\t\t\tcost=np.sum(list_C[h], axis=0)[0]\n\t\t\t#print(np.sum(list_C[h], axis=0),cost)\n\t\t\tcount+=1\n\tif count==0:\n\t\tbreak\n\nprint(cost if cost<100000001 else "-1")']
['Runtime Error', 'Accepted']
['s567983199', 's675895725']
[9016.0, 28288.0]
[24.0, 170.0]
[476, 532]
p02683
u609814378
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\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\n\nans = 10**10\n\nfor i in range(2**N):\n print("Hi")\n tmp_cost = []\n tmp_Algo = []\n for j in range(N):\n\n if ((i>>j)&1):\n tmp_cost.append(C[j])\n tmp_Algo.append(A[j])\n\n\n \n \n \n cost = 0\n flag = [0]*M\n\n for nedan in tmp_cost:\n cost = cost + nedan\n for singlelis in tmp_Algo:\n print(singlelis)\n \n\n\n \n \n\n\n\n', 'n, m, x = map(int, input().split())\nX = [list(map(int, input().split())) for _ in range(n)]\nans = 193934993409409\n\nfor mask in range(2 ** n):\n C = [0] * m\n cost = 0\n\n for i in range(n):\n if (mask >> i) & 1:\n cost += X[i][0]\n \n \n \n\n for j in range(1, m + 1):\n C[j - 1] += X[i][j]\n \n if min(C) >= x:\n ans = min(ans, cost)\n\nif ans < 91912922191:\n print(ans)\nelse:\n print(-1)\n']
['Wrong Answer', 'Accepted']
['s127259584', 's330800613']
[16484.0, 9200.0]
[265.0, 95.0]
[697, 762]
p02683
u613350811
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\ndef list_add(in1, in2):\n return list(map(sum, zip(in1, in2)))\n\nN, M ,X = map(int, input().split())\nC = [0] * N\nA = [[] * M] * N\nfor i in range(N):\n T = list(map(int, input().split()))\n C[i] = T[0]\n A[i] = T[1:]\n\nn = [i for i in range(N)]\nc_sum = 0\n\nfor i in range(N):\n min_sum = 10e5\n flag = 0\n for v in itertools.combinations(n,i+1):\n c_sum = 0\n At = [0] * M\n for j in range(len(v)):\n At = list_add(At, A[v[j]])\n c_sum += C[v[j]]\n over10 = [k for k in At if k >= 10]\n if len(over10) == M:\n print(v)\n min_sum = min([min_sum, c_sum])\n flag = 1\n if flag == 1:\n print(min_sum)\n exit()\nprint(-1)', 'import itertools\n\ndef list_add(in1, in2):\n return list(map(sum, zip(in1, in2)))\n\nN, M ,X = map(int, input().split())\nC = [0] * N\nA = [[] * M] * N\nfor i in range(N):\n T = list(map(int, input().split()))\n C[i] = T[0]\n A[i] = T[1:]\n\nn = [i for i in range(N)]\nc_sum = 0\n\nfor i in range(N):\n min_sum = 10e5\n flag = 0\n for v in itertools.combinations(n,i+1):\n c_sum = 0\n At = [0] * M\n for j in range(len(v)):\n At = list_add(At, A[v[j]])\n c_sum += C[v[j]]\n overX = [k for k in At if k >= X]\n if len(overX) == M:\n print(v)\n min_sum = min([min_sum, c_sum])\n flag = 1\n if flag == 1:\n print(min_sum)\n exit()\nprint(-1)', 'import itertools\n\ndef list_add(in1, in2):\n return list(map(sum, zip(in1, in2)))\n\nN, M ,X = map(int, input().split())\nC = [0] * N\nA = [[] * M] * N\nfor i in range(N):\n T = list(map(int, input().split()))\n C[i] = T[0]\n A[i] = T[1:]\n\nn = [i for i in range(N)]\nc_sum = 0\nmin_sum = 12 * 10e5\nfor i in range(N):\n flag = 0\n for v in itertools.combinations(n,i+1):\n c_sum = 0\n At = [0] * M\n for j in range(len(v)):\n At = list_add(At, A[v[j]])\n c_sum += C[v[j]]\n overX = [k for k in At if k >= X]\n if len(overX) == M:\n flag = 1\n min_sum = min([min_sum, c_sum])\nif flag == 1:\n print(min_sum)\nelse:\n print(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s267771081', 's510890101', 's362379841']
[9276.0, 9196.0, 9260.0]
[61.0, 66.0, 67.0]
[736, 733, 699]
p02683
u614162316
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.
['INF=100100100\n\nn,m,x=map(int,input().split())\nc=[]\na=[]\nfor i in range(n):\n t=list(map(int,input().split()))\n c.append(t[0])\n a.append(t[1:])\nprint(a)\ncost=INF\nfor i in range(n**2-1):\n ab=[0]*m\n tmp=0\n for j in range(n):\n idx=i>>j & 1\n if(idx):\n tmp+=c[j]\n for k in range(m):\n ab[k]+=a[j][k]\n for k in range(m):\n if(ab[k]<x):break\n else:cost=min(cost,tmp)\nif(INF==cost):print(-1)\nelse:print(cost)', 'INF=100100100\n\nn,m,x=map(int,input().split())\nc=[]\na=[]\nfor i in range(n):\n t=list(map(int,input().split()))\n c.append(t[0])\n a.append(t[1:])\ncost=INF\nfor i in range(2**n):\n ab=[0]*m\n tmp=0\n for j in range(n):\n idx=i>>j & 1\n if(idx):\n tmp+=c[j]\n for k in range(m):\n ab[k]+=a[j][k]\n for k in range(m):\n if(ab[k]<x):break\n else:cost=min(cost,tmp)\nif(INF==cost):print(-1)\nelse:print(cost)']
['Wrong Answer', 'Accepted']
['s211651112', 's443569676']
[9244.0, 9224.0]
[24.0, 80.0]
[478, 467]
p02683
u615576660
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\nnum_list = []\nfor i in range(n):\n num_list.append(list(map(int,input().split())))\n\n\nfor i in range(m):\n tate_sum=0\n for w in range(n):\n tate_sum = tate_sum + num_list[w][i+1]\n if tate_sum < x:\n print('-1')\n break", '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: 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)\n\nif ans == INF:\n ans = -1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s733043805', 's379769905']
[9196.0, 9256.0]
[23.0, 82.0]
[280, 582]
p02683
u619819312
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())\na=0\nb=[[np.array(list(map(int,input().split())))]for i in range(n)]\nfor i in range(2**n):\n c=bin(i)\n c="0"*(n-len(c))+c\n l=np.zeros(m)\n q=0\n for j in range(n):\n if c[j]=="1":\n q+=b[j][0]\n l+=b[j]\n if np.min(l)==x:\n a=min(a,q)\nif a:\n print(a)', 'import numpy as np\nn,m,x=map(int,input().split())\na=2**64\nb=[np.array(list(map(int,input().split())),"i8")for i in range(n)]\nfor i in range(2**n):\n c=bin(i)[2:]\n c="0"*(n-len(c))+c\n l=np.zeros(m)\n q=0\n for j in range(n):\n if c[j]=="1":\n q+=b[j][0]\n l+=b[j][1:]\n if np.min(l)>=x:\n a=min(a,q)\nif a==2**64:\n print(-1)\nelse:\n print(a)']
['Runtime Error', 'Accepted']
['s081382477', 's728076842']
[26980.0, 27092.0]
[116.0, 186.0]
[348, 390]
p02683
u620238824
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#n,m,x,i,j,l,money,k,o\nbooks = []\nfor i in range(n):\n books.append(list(map(int, input().split())))\nbooks = sorted(books, reverse=False)\nprint(books)#\n\nans = 10 ** 6\nimport itertools\nfor i in range(n+1):\n for j in itertools.combinations(books, i):\n# print(j)#\n l = [0] * n \n money = 0\n for k in j:\n# print(k)#\n money += k[0] \n# print(money)#\n for o in range(1, m + 1):\n l[o-1] += k[o] \n# print(money,l)\n if all(a >=x for a in l):\n if money < ans:\n ans = money\n\nif ans == 10 ** 6:\n print(-1)\nelse:\n print(ans)', 'n, m, x = map(int, input().split())\n#n,m,x,i,j,l,money,k,o\nbooks = []\nfor i in range(n):\n books.append(list(map(int, input().split())))\nbooks = sorted(books, reverse=False)\n#print(books)#\n\nans = 10 ** 10000\nimport itertools\nfor i in range(n+1):\n for j in itertools.combinations(books, i):\n# print(j)#\n l = [0] * m \n money = 0\n for k in j:\n# print(k)#\n money += k[0] \n# print(money)#\n for o in range(1, m + 1):\n l[o-1] += k[o] \n# print(money,l)#\n if all(a >=x for a in l):\n if money < ans:\n ans = money\n\nif ans == 10 ** 10000:\n print(-1)\nelse:\n print(ans)']
['Runtime Error', 'Accepted']
['s503264780', 's212129418']
[9232.0, 9236.0]
[83.0, 79.0]
[777, 787]
p02683
u625495026
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())\nd=[]\nans = []\nfor i in range(N):\n l=list(map(int,input().split()))\n d.append(l)\nprint(d)\nfor i in range(2**N):\n u=[0]*M\n price=0\n for j in range(N):\n if ((i>>j) & 1):\n price+=d[j][0]\n for k in range(M):\n u[k]+=d[j][k+1]\n if all(x>=X for x in u):\n ans.append(price)\nprint(min(ans) if len(ans) > 0 else -1) ', 'N,M,X = map(int,input().split())\nd=[]\nans = []\nfor i in range(N):\n l=list(map(int,input().split()))\n d.append(l)\nfor i in range(2**N):\n u=[0]*M\n price=0\n for j in range(N):\n if ((i>>j) & 1):\n price+=d[j][0]\n for k in range(M):\n u[k]+=d[j][k+1]\n if all(x>=X for x in u):\n ans.append(price)\nprint(min(ans) if len(ans) > 0 else -1) ']
['Wrong Answer', 'Accepted']
['s405807980', 's663073197']
[9212.0, 9192.0]
[85.0, 89.0]
[422, 413]
p02683
u628262476
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(' '))\na = np.zeros([n, m])\nc = np.zeros(n)\n\nfor i in range(n):\n v = list(map(int, input().split(' ')))\n a[i, :] = np.array(v[1:])\n c[i] = v[0]\n\nINF = 10000000000000000\nans = INF\n\nfor i in range(1<<n):\n skill = np.zeros(m)\n cost = 0\n for j in range(n):\n if i & (1<<j):\n cost += c[j]\n skill += a[j]\n if all(skill >= x):\n ans = min(ans, cost)\n\nprint(ans if ans != INF else -1)\n ", "import numpy as np\n\nn, m, x = map(int, input().split(' '))\na = np.zeros([n, m])\nc = np.zeros(n)\n\nfor i in range(n):\n v = list(map(int, input().split(' ')))\n a[i, :] = np.array(v[1:])\n c[i] = v[0]\n\nINF = 10000000000000000\nans = INF\n\nfor i in range(1<<n):\n skill = np.zeros(m)\n cost = 0\n for j in range(n):\n if i & (1<<j):\n cost += c[j]\n skill += a[j]\n if all(skill >= x):\n ans = min(ans, cost)\n\nprint(int(ans) if ans != INF else -1)\n \n"]
['Wrong Answer', 'Accepted']
['s638993084', 's789466352']
[27152.0, 27196.0]
[180.0, 153.0]
[452, 458]
p02683
u628794221
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 = [0]*N\nfor i in range(N):\n CA[i] = list(map(int, input().split()))\nprint(CA)\n\nINF = 10**7\nans = INF\nfor t in range(2**N):\n tmp = 0\n check = [X]*M\n for i in range(N):\n if (t >> i) & 1 == 1:\n tmp += CA[i][0]\n for j in range(M):\n check[j] -= CA[i][j+1]\n for ch in check:\n if ch > 0:\n break\n else:\n if tmp < ans:\n ans = tmp\n\nif ans == INF:\n print(-1)\nelse:\n print(ans)\n', 'N, M, X = map(int, input().split())\nCA = [0]*N\nfor i in range(N):\n CA[i] = list(map(int, input().split()))\n\nINF = 10**7\nans = INF\nfor t in range(2**N):\n tmp = 0\n check = [X]*M\n for i in range(N):\n if (t >> i) & 1 == 1:\n tmp += CA[i][0]\n for j in range(M):\n check[j] -= CA[i][j+1]\n for ch in check:\n if ch > 0:\n break\n else:\n if tmp < ans:\n ans = tmp\n\nif ans == INF:\n print(-1)\nelse:\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s172544185', 's165627279']
[9220.0, 9220.0]
[86.0, 82.0]
[509, 499]
p02683
u632413369
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())\nkumi = []\npat = list(range(N))\nfor _ in range(N):\n kumi.append(list(map(int, input().split())))\nans0 = 10 ** 5 * 12 + 1\nans = 10 ** 5 * 12 + 1\n#print(kumi)\ntest = []\nfor i in range(N):\n for i2 in itertools.combinations(kumi,i+1):\n arr_i2 = np.array(i2)\n arr_i2_sum = arr_i2.sum(axis = 0)\n if np.all(arr_i2_sum[1:] >= X):\n if ans > arr_i2_sum[0]:\n ans = arr_i2_sum[0]\nif ans == ans0:\n print(-1)\nelse:\n print(ans)import numpy as np\nimport itertools\nN, M, X = map(int, input().split())\nkumi = []\npat = list(range(N))\nfor _ in range(N):\n kumi.append(list(map(int, input().split())))\nans0 = 10 ** 5 * 12 + 1\nans = 10 ** 5 * 12 + 1\n#print(kumi)\ntest = []\nfor i in range(N):\n for i2 in itertools.combinations(kumi,i+1):\n arr_i2 = np.array(i2)\n arr_i2_sum = arr_i2.sum(axis = 0)\n if np.all(arr_i2_sum[1:] >= X):\n if ans > arr_i2_sum[0]:\n ans = arr_i2_sum[0]\nif ans == ans0:\n print(-1)\nelse:\n print(ans)', 'import numpy as np\nimport itertools\nN, M, X = map(int, input().split())\nkumi = []\npat = list(range(N))\nfor _ in range(N):\n kumi.append(list(map(int, input().split())))\nans = 10 ** 5 * 12\nkai = False\ntest = []\nfor i in range(N):\n for i2 in itertools.combinations(kumi,i+1):\n arr_i2 = np.array(i2)\n arr_i2_sum = arr_i2.sum(axis = 0)\n if np.all(arr_i2_sum[1:] >= X):\n if ans >= arr_i2_sum[0]:\n ans = arr_i2_sum[0]\n kai = True\nif kai:\n print(ans)\nelse:\n print(-1)']
['Runtime Error', 'Accepted']
['s051901488', 's107831223']
[8976.0, 27320.0]
[23.0, 156.0]
[1084, 533]
p02683
u635621124
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 as it\n\nN, M, X = map(int, input().split())\nbook = [[int(_) for _ in input().split()] for i in range(N)]\n\ncombs = it.product([0, 1], repeat=N)\nprices = []\nfor comb in combs:\n # print(comb)\n bag = [0] * M+1\n for i in range(N):\n if comb[i] == 0:\n continue\n else:\n for j in range(M+1):\n bag[j] += book[i][j]\n\n if min(bag[1:]) < X:\n continue\n else:\n prices.append(bag[0])\n\nif len(prices) == 0:\n print(-1)\nelse:\n print(min(prices))', 'import itertools as it\n\nN, M, X = map(int, input().split())\nbook = [[int(_) for _ in input().split()] for i in range(N)]\n\ncombs = it.product([0, 1], repeat=N)\nprices = []\nfor comb in combs:\n # print(comb)\n bag = [0] * (M+1)\n for i in range(N):\n if comb[i] == 0:\n continue\n else:\n for j in range(M+1):\n bag[j] += book[i][j]\n\n if min(bag[1:]) < X:\n continue\n else:\n prices.append(bag[0])\n\nif len(prices) == 0:\n print(-1)\nelse:\n print(min(prices))']
['Runtime Error', 'Accepted']
['s671099762', 's790903406']
[9204.0, 9280.0]
[26.0, 90.0]
[528, 530]
p02683
u636665812
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())\ndata=[]\nans=999999999\nb=[]\nb_pairs=[]\nfor i in range(N):\n b.append(i)\nfor i in range(N):\n data.append(list(map(int, input().split())))\n\nfor i in range(2,N+1):\n b_pairs+=itertools.combinations(b,i)\n\nfor i in range(N):\n flag=1\n skill=[0]*M\n for j in range(M):\n skill[j]+=data[i][j+1]\n for j in range(M):\n if skill[j]<X:\n flag=0\n if flag==1:\n ans=min(ans,data[i][0])\n\nfor i in range(len(b_pairs)):\n skill=[0]*M\n sum=0\n flag=1\n for k in range(len(b_pairs[i])):\n sum+=data[b_pairs[i][k]][0]\n for j in range(1,M+1):\n skill[j-1]+=data[b_pairs[i][k]][j]\n for h in range(M):\n if skill[h]<X:\n flag=0\n print(flag)\n if flag==1:\n ans=min(ans,sum)\n\nif ans==999999999:\n ans=-1\nprint(ans)', 'import itertools\n\nN,M,X=map(int, input().split())\ndata=[]\nans=999999999\nb=[]\nb_pairs=[]\nfor i in range(N):\n b.append(i)\nfor i in range(N):\n data.append(list(map(int, input().split())))\n\nfor i in range(2,N+1):\n b_pairs+=itertools.combinations(b,i)\n\nfor i in range(N):\n flag=1\n skill=[0]*M\n for j in range(M):\n skill[j]+=data[i][j+1]\n for j in range(M):\n if skill[j]<X:\n flag=0\n if flag==1:\n ans=min(ans,data[i][0])\n\nfor i in range(len(b_pairs)):\n skill=[0]*M\n sum=0\n flag=1\n for k in range(len(b_pairs[i])):\n sum+=data[b_pairs[i][k]][0]\n for j in range(1,M+1):\n skill[j-1]+=data[b_pairs[i][k]][j]\n for h in range(M):\n if skill[h]<X:\n flag=0\n if flag==1:\n ans=min(ans,sum)\n\nif ans==999999999:\n ans=-1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s930741986', 's178813587']
[9448.0, 9264.0]
[101.0, 96.0]
[852, 837]
p02683
u640603056
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\nfor i in range(1<<N):\t#Bit All Search\n\tl=[0]*(M+1)\n\tfor j in range(N):\n\t\tif((i>>j)&1)==1:\n\t\t\tl=[l[k]+A[j][k] for k in range(M+1)]\n\tfor k in range(M):\n\t\tif l[k+1]<X:\n\t\t\tbreak\n\telse:\n\t\tcost.append(l[0])\ncost.sort()\nprint(-1 if cost==[] else cost[0])', 'import sys\nN, M, X=map(int, sys.stdin.readline().rstrip().split())\nA = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(N)]\ncost=[]\nfor i in range(1<<N):\t#Bit All Search\n\tl=[0]*(M+1)\t\t\t#Initialize Check list\n\tfor j in range(N):\n\t\tif((i>>j)&1):\t#delete ==1\n\t\t\tl=[l[k]+A[j][k] for k in range(M+1)]\n\tfor k in range(M):\n\t\tif l[k+1]<X:\n\t\t\tbreak\n\telse:cost.append(l[0])\ncost.sort()\nprint(-1 if cost==[] else cost[0])']
['Runtime Error', 'Accepted']
['s709052802', 's366987639']
[9132.0, 9240.0]
[20.0, 69.0]
[258, 431]
p02683
u652656291
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(map(int,input().split()))\nA.sort(key=lambda x: x[0])\nmoney = 0\nans = 0\nfor i in range(n): \n c = A[i][0]\n a = A[i][1:]\n aa = min(a)\n money += c\n ans += aa\n if ans >= x:\n print(money())\n exit()\nprint(-1)\n', '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: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)\n\nif ans == INF:\n ans = -1\n\nprint(ans)\n \n \n']
['Runtime Error', 'Accepted']
['s610191945', 's593615164']
[9200.0, 9272.0]
[19.0, 84.0]
[257, 595]
p02683
u661647607
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 = [list(map(int, input().split())) for i in range(N)]\n\nAC_List = sorted(C_List, key=lambda x: x[0])\n\nans = [0]*(M+1)\nj = 0\n\nwhile all([i >= X for i in ans])==False and j <= N-1:\n ans = [a + b for a, b in zip(ans, AC_List[j])]\n j += 1\n\nif all([i >= X for i in ans])==False:\n ans[0] = -1\n\nprint(ans[0])', 'n, m, x = map(int,input().split())\nc = [list(map(int, input().split())) for i in range(n)]\nans = float(\'inf\')\nmoney = [float(\'inf\')]\n\nfor i in range(2**n):\n temp_money = 0\n temp_skill = [0]*m\n for j in range(n):\n if (i >> j) & 1:\n temp_money += c[j][0]\n temp_skill = [a + b for a, b in zip(temp_skill, c[j][1:m+1])]\n if all([i >= x for i in temp_skill])==True:\n money.append(temp_money)\n\nans = min(ans,min(money))\nif ans == float("inf"):\n ans = -1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s941593579', 's666537817']
[9216.0, 10172.0]
[23.0, 91.0]
[345, 484]
p02683
u668199686
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())\nlist_ca = [list(map(int, input().split())) for _ in range(n)]\n\nnum = pow(2, n)\nmin_cost = -1\nfor count in range(num):\n a_list = [0] * m\n cost = 0\n for i in range(n):\n bit = pow(2, i)\n if (count // bit) % 2 == 1:\n for j in range(m):\n a_list[j] = a_list[j] + list_ca[i][j + 1]\n cost += list_ca[i][0]\n if min(a_list) >= x:\n if min_cost == -1:\n min_cost = cost\n elif min_cost > cost:\n min_cost = cost\n print(a_list)\n\nprint(min_cost)', 'n, m, x = map(int, input().split())\nlist_ca = [list(map(int, input().split())) for _ in range(n)]\n\nnum = pow(2, n)\nmin_cost = -1\nfor count in range(num):\n a_list = [0] * m\n cost = 0\n for i in range(n):\n bit = pow(2, i)\n if (count // bit) % 2 == 1:\n for j in range(m):\n a_list[j] = a_list[j] + list_ca[i][j + 1]\n cost += list_ca[i][0]\n if min(a_list) >= x:\n if min_cost == -1:\n min_cost = cost\n elif min_cost > cost:\n min_cost = cost\n\nprint(min_cost)']
['Wrong Answer', 'Accepted']
['s002683958', 's528746216']
[9232.0, 9236.0]
[117.0, 114.0]
[566, 548]
p02683
u674588203
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 CanIGetEnoughSkills(SkillPoints,M,X):\n for _ in range(M):\n if SkillPoints[_]<X:\n return False\n else:\n pass\n return True\n\n\nN,M,X=map(int(input()).split())\nbooks=[input() for _ in range (N)]\n\nBookCost=[]\nGetSkillPoints=[]\nfor i in range (N):\n BookCost.append(books[i][0])\n GetSkillPoints.append(books[i][1:])\n\ntemp_cost=10**9\n\nfor Cart in range (2**len(GetSkillPoints)):\n TotalCost=0\n SkillPoints=[0]*M\n\n for book in range(len(GetSkillPoints)):\n if (Cart>>book)&1==0:\n continue\n TotalCost+= BookCost[book]\n for skillelement in range(M):\n SkillPoints[skillelement]+=GetSkillPoints[book][skillelement]\n\n # print(TotalCost,SkillPoints)\n if CanIGetEnoughSkills(SkillPoints,M,X)== True:\n temp_cost=min(temp_cost,TotalCost)\n\nAnswer=temp_cost\nif Answer==10**9:\n Answer=-1\n \nprint(Answer)', 'def CanIGetEnoughSkills(SkillPoints,M,X):\n for _ in range(M):\n if SkillPoints[_]<X:\n return False\n else:\n pass\n return True\n\n\nN,M,X=map(int,input().split())\nbooks=[]\nfor n in range(N):\n array= list(map(int,input().split()))\n books.append(array)\n# print(books)\n\nBookCost=[]\nGetSkillPoints=[]\nfor i in range (N):\n BookCost.append(int(books[i][0]))\n GetSkillPoints.append(books[i][1:])\n\ntemp_cost=10**9\n\nfor Cart in range (2**len(GetSkillPoints)):\n TotalCost=0\n SkillPoints=[0]*M\n \n for book in range(len(GetSkillPoints)):\n if (Cart>>book)&1==0:\n continue\n TotalCost+= BookCost[book]\n for skillelement in range(M):\n SkillPoints[skillelement]+=GetSkillPoints[book][skillelement]\n\n # print(TotalCost,SkillPoints)\n if CanIGetEnoughSkills(SkillPoints,M,X)== True:\n temp_cost=min(temp_cost,TotalCost)\n\nAnswer=temp_cost\nif Answer==10**9:\n Answer=-1\n \nprint(Answer)']
['Runtime Error', 'Accepted']
['s453279563', 's091287640']
[9136.0, 9260.0]
[24.0, 81.0]
[901, 983]
p02683
u676091297
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!\n\nn,m,k = map(int,input().split())\nlistA=[] \nwhile True:\n try:\n listA.append(list(map(int,input().split())))\n\n except:\n break;\n \nx=[[0] * (m+1) for i in range(2**n)] \n#print(listA)\nfor i in range(2 ** n):\n for j in range(n):\n if((i >> j) & 1 ):\n for l in range(m+1):\n x[i][l] += listA[j][l]\n \nprint(x)\n\ncnt = 10**9\nt = [k] * (m+1)\n#print(t)\nf = 0\nfor i in x:\n u = 0\n for j in range(1, m):\n if i[j] < t[j]:\n u = 1\n if u != 1:\n if cnt >= i[0]:\n cnt = i[0]\n f = 1\n #print(cnt) \nif f != 0:\n print(cnt)\nelse:\n print(-1)\n \n\n ', 'n,m,k = map(int,input().split())\nlistA=[] \nwhile True:\n try:\n listA.append(list(map(int,input().split())))\n\n except:\n break;\n \nx=[[0] * (m+1) for i in range(2**n)] \n#print(listA)\nfor i in range(2 ** n):\n for j in range(n):\n if((i >> j) & 1 ):\n for l in range(m+1):\n x[i][l] += listA[j][l]\n \nprint(x)\n\ncnt = 10**9\nt = [k] * (m+1)\nprint(t)\nfor i in x:\n u = 0\n for j in range(1, m):\n if i[j] < t[j]:\n u = 1\n if u != 1:\n if cnt >= i[0]:\n cnt = i[0]\n #print(cnt) \nif cnt != 10**9:\n print(cnt)\nelse:\n print(-1)\n \n', '# coding: utf-8\n# Your code here!\n\nn,m,k = map(int,input().split())\nlistA=[] \nwhile True:\n try:\n listA.append(list(map(int,input().split())))\n\n except:\n break;\n \nx=[[0] * (m+1) for i in range(2**n)] \n#print(listA)\nfor i in range(2 ** n):\n for j in range(n):\n if((i >> j) & 1 ):\n for l in range(m+1):\n x[i][l] += listA[j][l]\n \n#print(x)\n#print(list(range(1,m+1)))\ncnt = 10**10\nt = [k] * (m+1)\n#print(t)\nf = 0\nfor i in x:\n #print(i)\n u = 0\n for j in range(1, m+1):\n #print(1)\n if i[j] < t[j]:\n u = 1\n if u != 1:\n if cnt >= i[0]:\n cnt = i[0]\n f = 1\n #print(cnt) \nif f != 0:\n print(cnt)\nelse:\n print(-1)\n\n\n \n ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s619636118', 's664092560', 's951773026']
[12108.0, 12168.0, 11124.0]
[108.0, 102.0, 98.0]
[818, 749, 860]
p02683
u678505520
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\nif __name__ == \'__main__\':\n n, m, x = list(map(int, input().split()))\n\n \n c = [] \n a = [] \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)\n\ndef 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): を加算します enumerateを使うと、range(n)よりスマートです\n learn_total[j] += la\n\n \n if check(learn_total):\n return price_total \n else:\n return INF \n\ndef check(learn_total):\n for i in range(m):\n if learn_total[i] < x:\n return False \n return True ', 'if __name__ == \'__main__\':\n n, m, x = list(map(int, input().split()))\n\n c = []\n a = []\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)\n\ndef 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 \n if check(learn_total):\n return price_total \n else:\n return INF \n\ndef check(learn_total):\n for i in range(m):\n if learn_total[i] < x:\n return False \n return True ', 'def check(learn_total):\n for i in range(m):\n if learn_total[i] < x:\n return False \n return True \n\ndef 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 \n if check(learn_total):\n return price_total \n else:\n return INF\n\nif __name__ == \'__main__\':\n n, m, x = list(map(int, input().split()))\n\n \n c = [] \n a = [] \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) ']
['Runtime Error', 'Runtime Error', 'Accepted']
['s147070656', 's492937696', 's918615587']
[9232.0, 9248.0, 9248.0]
[23.0, 21.0, 56.0]
[1861, 907, 1286]
p02683
u684267998
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.
['\nimport itertools\nimport sys\nimport numpy as np\nINF = float("inf")\nN, M, x= map(int, input().split())\nnap = []\n\nfor _ in range(N):\n nap.append(list(map(int, input().split()))) \nmon=[]\nvalue=[]\nfor x in nap:\n mon.append(x[0])\nfor y in nap:\n value.append(y[1:])\nmon=np.array(mon)\nvalue=np.array(value)\nfor i in itertools.product((0,1),repeat=N):\n choice = np.array(list(i), dtype=bool)\n if all(value[choice,:].sum(axis=0) >=x):\n ans = min(ans,mon[choice].sum())\nif ans == INF:\n print(-1)\nelse:\n print(ans)\n\n \n', 'N, M, x= map(int, input().split())\ndp=[[0 for i in range(N+1)] for j in range(M+1)]\nnap = []\ndp[0][0]=0\nansw = [10]*M\nfor _ in range(N):\n nap.append(list(map(int, input().split()))) \n\nmon=[]\nvalue=[]\nfor x in nap:\n mon.append(x[0])\nfor y in nap:\n value.append(y[1:])\n\nans = []\nfor i in range(N):\n for j in range(M):\n dp[i+1][j+1] = dp[i][j]+value[i][j]\nfor m in range(M):\n if answ[m] > ans[m]:\n print(-1)\n exit()\n\n\nreturn dp[N][W]', 'N, M, x= map(int, input().split())\ndp=[[0 for i in range(N+1)] for j in range(M+1)]\nnap = []\ndp[0][0]=0\nansw = [10]*M\nfor _ in range(N):\n nap.append(list(map(int, input().split()))) \n\nmon=[]\nvalue=[]\nfor x in nap:\n mon.append(x[0])\nfor y in nap:\n value.append(y[1:])\n\nans = []\nfor i in range(N):\n for j in range(M):\n dp[i+1][j+1] = dp[i][j]+value[i][j]\nfor m in range(M):\n if answ[m] > ans[m]:\n print(-1)\n exit()\n\n\nreturn dp[N][M]\n', '\nimport itertools\nimport sys\nimport numpy as np\nINF = float("inf")\nN, M, X = list(map(int, sys.stdin.buffer.readline().split()))\nA = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]\n \nA = np.array(A, dtype=int)\nmat = A[:, 1:]\nC = A[:, 0]\n \nans = INF\nfor choices in itertools.product((True, False), repeat=N):\n choices = np.array(list(choices), dtype=bool)\n if np.all(mat[choices, :].sum(axis=0) >= X):\n ans = min(ans, C[choices].sum())\nif ans == INF:\n print(-1)\nelse:\n print(ans)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s271851274', 's525369775', 's946913133', 's783446016']
[27160.0, 9076.0, 9108.0, 27212.0]
[100.0, 22.0, 19.0, 163.0]
[538, 466, 467, 522]
p02683
u686036872
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\nA = []\nfor i in range(N):\n A.append(list(map(int, input().split())))\n\nsaisyo = float("inf")\nfor i in intertools.product(range(2), N):\n a = [0]*M\n gokei = 0\n for j in range(N):\n if i[j] == 1:\n gokei += A[j][0]\n for k in range(1, M+1):\n a[k-1] += A[j][k]\n if min(a) >= X:\n saisyo = min(saisyo, gokei)\n\nprint(saisyo if saisyo != float("inf") else -1)', 'import itertools\n\nN, M, X = map(int, input().split())\n\nA = []\nfor i in range(N):\n A.append(list(map(int, input().split())))\n\nsaisyo = float("inf")\nfor i in itertools.product(range(2), repeat=N):\n a = [0]*M\n gokei = 0\n for j in range(N):\n if i[j] == 1:\n gokei += A[j][0]\n for k in range(1, M+1):\n a[k-1] += A[j][k]\n if min(a) >= X:\n saisyo = min(saisyo, gokei)\n\nprint(saisyo if saisyo != float("inf") else -1)']
['Runtime Error', 'Accepted']
['s768259656', 's115095713']
[9228.0, 9252.0]
[23.0, 81.0]
[468, 474]
p02683
u689890477
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)]\nc = [ca[i][0] for i in range(n)]\na = [ca[i][1:] for i in range(n)]\nl = 0\nfor i in range(2 ** n):\n ans = sum(c)\n get = [0] * m\n kari = 0\n for j in range(n):\n if (i >> j) & 1:\u3000\n get = [x + y for (x, y) in zip(get, a[j])]\n kari += c[j]\n if all([z >= x for z in get]):\n ans = min(ans,kari)\n l += 1\nif l == 0:\n ans = -1\n\nprint(ans)\n\n \n ', 'n,m,x = map(int,input().split())\nca = [list(map(int,input().split())) for _ in range(n)]\nc = [ca[i][0] for i in range(n)]\na = [ca[i][1:] for i in range(n)]\nl = 0\nfor i in range(2 ** n):\n ans = sum(c)\n get = [0] * m\n kari = 0\n for j in range(n):\n if (i >> j) & 1: \n get = [x + y for (x, y) in zip(get, a[j])]\n kari += c[j]\n if all([z >= x for z in get]):\n ans = min(ans,kari)\n l += 1\nif l == 0:\n ans = -1\n\nprint(ans)\n', 'n,m,x = map(int,input().split())\nca = [list(map(int,input().split())) for _ in range(n)]\nc = [ca[i][0] for i in range(n)]\na = [ca[i][1:] for i in range(n)]\nl = 0\nfor i in range(2 ** n):\n ans = 0\n get = [0] * m\n kari = 0\n for j in range(n):\n if (i >> j) & 1:\n get = [x + y for (x, y) in zip(get, a[j])]\n kari += c[j]\n if all([z >= x for z in get]):\n ans = min(ans,kari)\n l += 1\nif l == 0:\n ans = -1\n\nprint(ans)\n\n ', 'n,m,x = map(int,input().split())\nca = [list(map(int,input().split())) for _ in range(n)]\nc = [ca[i][0] for i in range(n)]\na = [ca[i][1:] for i in range(n)]\nl = 0\nans = sum(c) \nfor i in range(2 ** n):\n get = [0] * m\n kari = 03 \n for j in range(n):\n if (i >> j) & 1: \n get = [x + y for (x, y) in zip(get, a[j])]\n kari += c[j]\n #print(get,kari)\n #print([k >= x for k in get])\n if all([k >= x for k in get]):\n ans = min(ans,kari)\n l += 1\nif l == 0:\n ans = -1\n \nprint(ans)\n ', 'n,m,x = map(int,input().split())\nca = [list(input().split()) for _ in range(n)]\nc = [ca[i][0] for i in range(n)]\na = [ca[i][1:] for i in range(n)]\nl = 0\nfor i in range(2 ** n):\n get = [0] * m\n kari = 0\n for j in range(n):\n if (i >> j) & 1:\n get = [x + y for (x, y) in zip(ab, a[j])]\n kari += c[j]\n if all([z >= x for z in get]):\n ans = min(ans,kari)\n l += 1\nif l == 0:\n ans = -1\n\nprint(ans)\n\n ', 'n,m,x = map(int,input().split())\nca = [list(map(int,input().split())) for _ in range(n)]\nc = [ca[i][0] for i in range(n)]\na = [ca[i][1:] for i in range(n)]\n\nprice = sum(c)\nl =0\n\nfor i in range(2**n):\n kari = 0\n skill = [0]*m\n for j in range(n):\n if (i>>j) & 1:\n skill = [x + y for(x,y) in zip(skill,a[j]) ]\n kari += c[j]\n if all([z >= x for z in skill]):\n price = min(price, kari)\n l += 1\n\nif l == 0:\n print(-1)\nelse:\n print(price)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s015045111', 's325203710', 's330649318', 's440442908', 's821325334', 's776728468']
[9068.0, 9180.0, 9232.0, 9048.0, 9240.0, 9244.0]
[27.0, 58.0, 55.0, 22.0, 21.0, 60.0]
[552, 524, 484, 587, 462, 492]
p02683
u692311686
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 tmpA=list(map(int,input().split()))\n C+=[tmpA[0]]\n A[i]=tmpA[1:]\ntf=1\nfor i in range(M):\n s=0\n for j in range(N):\n s+=A[j][i]\n if s<X:\n tf=0\n break\nif tf==0:\n print(-1)\nelse:\n costmin=float('inf')\n for k in range(2**N):\n tansaku=k\n koubai=[0 for i in range(N)]\n rikaido=[0 for i in range(N)]\n cost=0\n for i in range(N-1):\n koubai[i]=tansaku//(2**(N-i-1))\n tansaku=tansaku%(2**(N-i-1))\n koubai[-1]=tansaku\n for i in range(N):\n if koubai[i]==1:\n cost+=C[i]\n for j in range(M):\n rikaido[j]+=A[i][j]\n for i in range(M):\n if rikaido[i]<X:\n break\n else:\n costmin=min(costmin,cost)\n \n \n \n ", "N,M,X=map(int,input().split())\nC=[]\nA=[[] for _ in range(N)]\nfor i in range(N):\n tmpA=list(map(int,input().split()))\n C+=[tmpA[0]]\n A[i]=tmpA[1:]\n\ncostmin=float('inf')\nfor k in range(2**N):\n tansaku=k\n koubai=[0 for i in range(N)]\n rikaido=[0 for i in range(M)]\n cost=0\n for i in range(N-1):\n koubai[i]=tansaku//(2**(N-i-1))\n tansaku=tansaku%(2**(N-i-1))\n koubai[-1]=tansaku\n for i in range(N):\n if koubai[i]==1:\n cost+=C[i]\n for j in range(M):\n rikaido[j]+=A[i][j]\n for i in range(M):\n if rikaido[i]<X:\n break\n else:\n costmin=min(costmin,cost)\nif costmin!=float('inf'):\n print(costmin)\nelse:\n print(-1)"]
['Runtime Error', 'Accepted']
['s800394475', 's850304141']
[9240.0, 9216.0]
[109.0, 108.0]
[785, 656]
p02683
u693716675
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())\ncosts = [list(map(int, input().split())) for _ in range(n)]\n\n\n\n\nINF = 1000000000000000000000000000\nans = INF\n\nfor i in range(1<<n): #n bits all searches\n # 1<<n == 2**n\n c = 0\n sums = [0]*m\n for j in range(n):\n if i>>j & 1: #i>>j %2 == 1 is also fine.\n #apply this candidate. \n c += costs[j][0]\n for k in range(m):\n sums[k] += costs[j][k+1]\n \n'''\n cost = 0\n c = 0\n sums = [0] * m\n use_index=[]\n for j in range(n):\n if i%2==1:\n use_index.append(j)\n i >>= 1\n \n for v in use_index:\n c += costs[v][0] \n for j in range(m):\n sums[j] += costs[v][j+1]\n'''\n\n if min(sums) >= x:\n ans = min(ans, c)\n\n''' \n judge=True\n for j in range(m):\n if sums[j]<x:\n judge=False\n break\n \n if judge:\n ans = min(ans, c)\n'''\nans = -1 if ans==INF \nprint(ans)\n\n", "n,m,x = map(int, input().split())\ncosts = [list(map(int, input().split())) for _ in range(n)]\n\n\n\n\nINF = 1000000000000000000000000000\nans = INF\n\nfor i in range(1<<n): #n bits all searches\n # 1<<n == 2**n\n c = 0\n sums = [0]*m\n for j in range(n):\n if i>>j & 1: #i>>j %2 == 1 is also fine.\n #apply this candidate. \n c += costs[j][0]\n for k in range(m):\n sums[k] += costs[j][k+1] \n '''\n cost = 0\n c = 0\n sums = [0] * m\n use_index=[]\n for j in range(n):\n if i%2==1:\n use_index.append(j)\n i >>= 1\n \n for v in use_index:\n c += costs[v][0] \n for j in range(m):\n sums[j] += costs[v][j+1]\n '''\n \n #if min(sums) >= x:\n if all(s>=x for x in sums):\n ans = min(ans, c)\n''' \n judge=True\n for j in range(m):\n if sums[j]<x:\n judge=False\n break\n \n if judge:\n ans = min(ans, c)\n'''\nif ans==INF:\n print(-1)\nelse:\n print(ans)\n \n", "#abc_167_c\n\n\nfrom itertools import product\n\nn,m,x = map(int, input().split())\ncosts = [list(map(int, input().split())) for _ in range(n)]\n\nINF = 1000000000000000000000000000\nans = INF\n\n\nlists = list(product(list(range(2)), repeat = n))\nfor v in lists:\n'''\nfor i in range(1<<n): #n bits all searches\n # 1<<n == 2**n\n'''\n c = 0\n sums = [0]*m\n for j in range(n):\n if v[j]==1: \n '''\n if i>>j & 1: #i>>j %2 == 1 is also fine.\n '''\n #apply this candidate. \n c += costs[j][0]\n for k in range(m):\n sums[k] += costs[j][k+1] \n \n \n if min(sums) >= x: \n ans = min(ans, c) \n \n \n \nif ans==INF:\n print(-1)\nelse:\n print(ans)", "#abc_167_c\n\n\nfrom itertools import product\n\nn,m,x = map(int, input().split())\ncosts = [list(map(int, input().split())) for _ in range(n)]\n\nINF = 1000000000000000000000000000\nans = INF\n\n\nlists = list(product(list(range(2)), repeat = n))\nfor v in lists:\n '''\n for i in range(1<<n): #n bits all searches\n # 1<<n == 2**n\n '''\n c = 0\n sums = [0]*m\n for j in range(n):\n if v[j]==1: \n '''\n if i>>j & 1: #i>>j %2 == 1 is also fine.\n '''\n #apply this candidate. \n c += costs[j][0]\n for k in range(m):\n sums[k] += costs[j][k+1] \n \n \n if min(sums) >= x: \n ans = min(ans, c) \n \n \n \nif ans==INF:\n print(-1)\nelse:\n print(ans)"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s204160115', 's560798828', 's933492513', 's448812336']
[8976.0, 9140.0, 9052.0, 9660.0]
[21.0, 23.0, 24.0, 83.0]
[1125, 1184, 1042, 1070]
p02683
u693723949
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()]\nc = []\na = []\nfor i in range(n):\n tmp = [int(x) for x in input().split()]\n c.append(tmp[0])\n a.append(tmp[1:])\n\nans = 10**8 # as INF\nfor s in range(2**n):\n s = bin(s)\n cost = 0\n d = [0 for j in range(m)]\n for i in range(n):\n is_use = bin(s>>i&1) == bin(1)\n if is_use:\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 and cost < ans:\n ans = cost\nprint(ans)\n \t\n', 'n, m, x = [int(x) for x in input().split()]\nc = []\na = []\nfor i in range(n):\n tmp = [int(x) for x in input().split()]\n c.append(tmp[0])\n a.append(tmp[1:])\n\nans = 10**8 # as INF\nfor s in range(2**n):\n cost = 0\n d = [0 for j in range(m)]\n for i in range(n):\n is_use = bin(s>>i&1) == bin(1)\n if is_use:\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 and cost < ans:\n ans = cost\nif ans == 10**8:\n print(-1)\nelse:\n print(ans)\n \t\n']
['Runtime Error', 'Accepted']
['s203482679', 's096710927']
[9140.0, 9248.0]
[25.0, 87.0]
[522, 546]
p02683
u694380052
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=[]\nans=10**6\nfor x in range(n):\n line=list(map(int,input().split()))\n c.append(line[0])\n a.append(line[1:])\na=np.array(a)\nfor i in range(2**n):\n level=np.zeros(m)\n price=0\n for j in range(n):\n if ((i>>j)&1):\n level+=a[j]\n price+=c[j]\n\tfor k in range(m):\n if np.amin(level)>=x and price<=ans:\n ans=price\nif ans==10**6:\n print(-1)\nelse:\n print(ans)', 'import numpy as np\n\nn,m,x=map(int, input().split())\nsl=[]\npl=[]\nfor k in range(n):\n book=list(map(int,input().split()))\n sl.append(book[1:])\n pl.append(book[0])\n \nsl=np.array(sl)\nans=10**8\n\nfor i in range(2**n):\n skill=np.zeros(m)\n price=0\n for j in range (n):\n if ((i>>j)&1):\n skill+=sl[j]\n price+=pl[j]\n bottom=np.amin(skill)\n if bottom>=x and price<ans:\n ans=price\nif ans==10**8:\n print(-1)\nelse:\n print(ans)']
['Runtime Error', 'Accepted']
['s792400899', 's269487232']
[8916.0, 26956.0]
[26.0, 190.0]
[436, 438]
p02683
u696444274
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.
['\nfrom fractions import gcd\nfrom functools import reduce\n# from collections import deque\n# from math import factorial\nimport collections\nimport math\nimport sys\nsys.setrecursionlimit(2000000)\n# import itertools\n# import statistics\n# import numpy as np\n# n = int(input())\n\n# a = list(map(int, input().split()))\n\n# n = int(input())\n# n, m = list(map(int, input().split()))\nn, m, x = list(map(int, input().split()))\n# a = list(map(int, input().split()))\n\n# n = int(input())\n# n, m = list(map(int, input().split()))\na = []\nfor i in range(n):\n b = list(map(int, input().split()))\n t = sum(b)-b[0]\n # print(t)\n b.append(b[0]/t)\n a.append(b)\n\na_sorted = sorted(a, key=lambda x: x[-1])\n\n\nmoney = 0\npoint = [0]*m\nover = [0]*m\nfor i in range(n):\n fin = True\n money += a_sorted[i][0]\n for j in range(m):\n point[j] += a_sorted[i][j+1]\n for j in range(m):\n if point[j] < x:\n fin = False\n else:\n over[j] = point[j]-x\n if fin:\n k = []\n for i in range(n):\n kouho = True\n for j in range(m):\n if a_sorted[i][j+1] > over[j]:\n kouho = False\n if kouho:\n k.append(i)\n k.sort(reverse=True)\n if len(k) != 0:\n for i in range(len(k)):\n for j in range(m):\n point[j] -= a_sorted[i][j+1]\n if point[j] < x:\n print(money)\n exit()\n money -= a_sorted[i][0]\n # print(over)\n for j in range(m):\n print(money)\n exit()\n # print(check)\nprint(-1)\n', '\nfrom fractions import gcd\nfrom functools import reduce\n# from collections import deque\n# from math import factorial\nimport collections\nimport math\nimport sys\nsys.setrecursionlimit(2000000)\nn, m, x = list(map(int, input().split()))\n# a = list(map(int, input().split()))\n\n#n = int(input())\n# n, m = list(map(int, input().split()))\na = []\nfor i in range(n):\n b = list(map(int, input().split()))\n t = sum(b)-b[0]\n #print(t)\n b.append(b[0]/t)\n a.append(b)\n\na_sorted = sorted(a, key=lambda x: x[-1])\n\nmoney = 0\npoint = [0]*m\nfor i in range(n):\n fin = True\n money += a_sorted[i][0]\n for j in range(m):\n #print(money)\n point[j] += a_sorted[i][j+1]\n \n #print(point, end=" ")\n #print(money)\n for j in range(m):\n if point[j] < x:\n fin = False\n if fin:\n print(money)\n exit()\n\n # print(check)\nprint(-1)\n\n', 'n, m, x = list(map(int, input().split()))\n\na = []\nfor i in range(n):\n b = list(map(int, input().split()))\n a.append(b)\n\n\ndef calcPoint(point, n):\n for i in range(m):\n point[i] += a[n][i+1]\n return point\n\n\ndef judgePoint(point):\n for i in range(m):\n if point[i] < x:\n return False\n return True\n\n\nans = []\nfor i in range(2**n): \n buy = []\n for j in range(n): \n if((i >> j) & 1): \n buy.append(1)\n else:\n buy.append(0)\n price = 0\n point = [0]*m\n for i in range(n):\n if buy[i] == 1:\n calcPoint(point, i)\n price += a[i][0]\n if judgePoint(point):\n ans.append(price)\nif len(ans) == 0:\n print(-1)\nelse:\n print(min(ans))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s481933661', 's626709349', 's766255604']
[10484.0, 10480.0, 9252.0]
[35.0, 31.0, 77.0]
[1795, 947, 811]
p02683
u701893485
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, M, X = map(int, input().split(\' \'))\n book_list = [None]*N\n min_price = -1\n for i in range(N):\n book_list[i] = list(map(int, input().split(\' \')))\n\n for i in range(2 ** N):\n comp_list = []\n for j in range(N):\n if ((i >> j) & 1):\n if comp_list == []:\n comp_list = book_list[j]\n else:\n comp_list = [a+b for a, b in zip(comp_list, book_list[j])]\n print(comp_list)\n if all(comp >= X for comp in comp_list):\n if min_price == -1:\n min_price = comp_list[0]\n elif comp_list[0] < min_price:\n min_price = comp_list[0]\n print(min_price)', 'if __name__=="__main__":\n N, M, X = map(int, input().split(\' \'))\n book_list = [None]*N\n min_price = -1\n for i in range(N):\n book_list[i] = list(map(int, input().split(\' \')))\n\n for i in range(2 ** N):\n comp_list = []\n for j in range(N):\n if ((i >> j) & 1):\n if comp_list == []:\n comp_list = book_list[j]\n else:\n comp_list = [a + b for a, b in zip(comp_list, book_list[j])]\n\n if all(comp >= X for comp in comp_list):\n if min_price == -1:\n pass\n elif comp_list[0] <= min_price:\n min_price = comp_list[0]\n print(min_price)', 'if __name__=="__main__":\n N, M, X = map(int, input().split(\' \'))\n book_list = [None]*N\n min_price = -1\n for i in range(N):\n book_list[i] = list(map(int, input().split(\' \')))\n\n for i in range(2 ** N):\n comp_list = []\n for j in range(N):\n if ((i >> j) & 1):\n if comp_list == []:\n comp_list = book_list[j]\n else:\n comp_list = [a + b for a, b in zip(comp_list, book_list[j])]\n\n if all(comp >= X for comp in comp_list[1:]):\n if min_price == -1:\n min_price = comp_list[0]\n elif comp_list[0] <= min_price:\n min_price = comp_list[0]\n print(min_price)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s188070922', 's341430511', 's267320923']
[9220.0, 9236.0, 9236.0]
[109.0, 67.0, 69.0]
[784, 735, 759]
p02683
u703672022
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.
['blist = []\ndef createBitline(N, p, bl):\n\tif(N == p):\n\t\tblist.append(bl)\n\telse:\n\t\tcreateBitline(N, p + 1, bl + "0")\n\t\tcreateBitline(N, p + 1, bl + "1")\n\n\n\ndef checkClear(X, M, list):\n\tfor i in range(1, M):\n\t\tif X > int(list[i]):\n\t\t\treturn False\n\treturn True\n\nlistCA = []\ndef main3():\n\tN,M,X = map(int, input().split())\n\tfor i in range(N):\n\t\tlistCA.append(input().split())\n\tcreateBitline(N, 0, "")\n\tmax = 1000000000\n\tflg = False\n\t\n\tfor x in range(len(blist)):\n\t\tsumCA = [0] * M\n\t\t\n\t\tfor i in range(N):\n\t\t\tif blist[x][i] == "1":\n\t\t\t\tfor j in range(M):\n\t\t\t\t\tsumCA[j] += int(listCA[i][j])\n\t\t\n\t\tif checkClear(X, M, sumCA) and sumCA[0] < max:\n\t\t\tmax = sumCA[0]\n\t\t\tflg = True\n\tif flg:\n\t\tprint(max)\n\telse:\n\t\tprint("-1")', 'blist = []\ndef createBitline(N, p, bl):\n\tif(N == p and len(bl) == N):\n\t\tblist.append(bl)\n\telse:\n\t\tcreateBitline(N, p + 1, bl + "0")\n\t\tcreateBitline(N, p + 1, bl + "1")\n\ndef checkClear(X, list):\n\tfor i in range(1, len(list)):\n\t\tif int(list[i]) < X:\n\t\t\treturn False\n\treturn True\n\nlistCA = []\nN,M,X = map(int, input().split())\nfor i in range(N):\n\tlistCA.append(input().split())\nfor i in listCA:\n\tprint(i)\ncreateBitline(N, 0, "")\ncost = []\nfor x in range(len(blist)):\n\tsumCA = [0] * (M + 1)\n\tfor i in range(N):\n\t\tif blist[x][i] == "1":\n\t\t\tfor j in range(len(listCA[i])):\n\t\t\t\tsumCA[j] += int(listCA[i][j])\n\tif checkClear(X, sumCA):\n\t\tcost.append(sumCA[0])\nif cost:\n\tprint(min(cost))\nelse:\n\tprint(\'-1\')', 'blist = []\ndef createBitline(N, p, bl):\n\tif(N == p and len(bl) == N):\n\t\tblist.append(bl)\n\telse:\n\t\tcreateBitline(N, p + 1, bl + "0")\n\t\tcreateBitline(N, p + 1, bl + "1")\n \ndef checkClear(X, list):\n\tfor i in range(1, len(list)):\n\t\tif int(list[i]) < X:\n\t\t\treturn False\n\treturn True\n \nlistCA = []\nN,M,X = map(int, input().split())\nfor i in range(N):\n\tlistCA.append(input().split())\ncreateBitline(N, 0, "")\ncost = []\nfor x in range(len(blist)):\n\tsumCA = [0] * (M + 1)\n\tfor i in range(N):\n\t\tif blist[x][i] == "1":\n\t\t\tfor j in range(len(listCA[i])):\n\t\t\t\tsumCA[j] += int(listCA[i][j])\n\tif checkClear(X, sumCA):\n\t\tcost.append(sumCA[0])\nif cost:\n\tprint(min(cost))\nelse:\n\tprint(\'-1\')']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s121188798', 's719835477', 's096511449']
[9140.0, 9348.0, 9440.0]
[22.0, 137.0, 133.0]
[1009, 696, 671]
p02683
u703823201
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 sub, add\nimport sys\nN, M, X = map(int, input().split())\nAC = []\nfor _ in range(N):\n AC.append(list(map(int, input().split())))\n\nS = [sum(x) for x in zip(*AC)]\ns = [sum(x) for x in zip(*AC)]\nfor m in range(1, M+1):\n if s[m] < X:\n print(-1)\n sys.exit(0)\n \nAC.sort(reverse=True) \nfor n in range(N):\n ac = AC[n]\n s = list(map(sub, s, ac))\n for m in range(1, M+1):\n if s[m] < X:\n s = list(map(add, s, ac))\n break\n \nprint(min(S, s[0]))', 'import itertools as it\n\nN,M,X=map(int,input().split())\nbook = [[int(_) for _ in input().split()] for i in range(N)]\n\ncombs = it.product([0, 1], repeat=N)\nprices = []\nfor comb in combs:\n\tbag = [0] * (M+1)\n\tfor i in range(N):\n\t\tif comb[i] == 0:\n\t\t\tcontinue\n\t\telse:\n\t\t\tfor j in range(M+1):\n\t\t\t\tbag[j]+=book[i][j]\n\tif min(bag[1:]) < X:\n\t\tcontinue\n\telse:\n\t\tprices.append(bag[0])\n\nif len(prices) == 0:\n\tprint(-1)\nelse:\n\tprint(min(prices))\n']
['Runtime Error', 'Accepted']
['s334183813', 's239348496']
[9320.0, 9240.0]
[25.0, 93.0]
[533, 433]
p02683
u707030679
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\nN=[]\nNI=[]\nfor i in range(n) :\n N = list(map(str, input().split()))\n NI.append(N)\n\nans=-1\n\nfor i in range(1<<n) :\n A=[0]*(m+1)\n for j in range(n) :\n # print(NI[j])\n if (1<<j)&i :\n A=[x+int(y) for(x,y)in zip(A,NI[j])]\n print(A)\n a = A[0]\n del A[0]\n if min(A)<x :\n a=-1\n elif ans==-1:\n ans = a\n elif ans>a :\n ans = a\nprint(ans)\n', 'n,m,x = map(int, input().split())\n\nN=[]\nNI=[]\nfor i in range(n) :\n N = list(map(str, input().split()))\n NI.append(N)\n\nans=-1\n\nfor i in range(1<<n) :\n A=[0]*(m+1)\n for j in range(n) :\n # print(NI[j])\n if (1<<j)&i :\n A=[x+int(y) for(x,y)in zip(A,NI[j])]\n # print(A)\n a = A[0]\n del A[0]\n if min(A)<x :\n a=-1\n elif ans==-1:\n ans = a\n elif ans>a :\n ans = a\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s497445864', 's059228066']
[9168.0, 9064.0]
[100.0, 99.0]
[437, 439]
p02683
u711295009
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())\nsL = [0]*m\nbL = []\nfor i in range(n):\n book = list(map(int, input().split()))\n bL.append(book)\n\n\ndef fullS(currentL, index, allP):\n if index > len(currentL):\n if min(currentL) >= x:\n return allP\n else:\n return -1\n else:\n if min(currentL) >= x:\n return allP\n else:\n op1 = fullS(currentL, index+1, allP)\n newP = 0\n newL = []\n for i in range(len(bL[index])):\n if i == 0:\n newP = allP+bL[index][i]\n else:\n newL.append(currentL[i-1]+bL[index][i])\n op2 = fullS(newL, index+1, newP)\n if op1 == -1 and op2 == -1:\n return -1\n elif op1 == -1:\n return op2\n elif op2 == -1:\n return op1\n else:\n return min(op1, op2)\n \n\n\nprint(fullS(sL, 0, 0))', 'n, m, x = map(int, input().split())\nsL = [0]*m\nbL = []\nfor i in range(n):\n book = list(map(int, input().split()))\n bL.append(book)\n\n\ndef fullS(currentL, index, allP):\n if index >= len(bL):\n if min(currentL) >= x:\n return allP\n else:\n return -1\n else:\n if min(currentL) >= x:\n return allP\n else:\n op1 = fullS(currentL, index+1, allP)\n newP = 0\n newL = []\n for i in range(len(bL[index])):\n if i == 0:\n newP = allP+bL[index][i]\n else:\n newL.append(currentL[i-1]+bL[index][i])\n op2 = fullS(newL, index+1, newP)\n if op1 == -1 and op2 == -1:\n return -1\n elif op1 == -1:\n return op2\n elif op2 == -1:\n return op1\n else:\n return min(op1, op2)\n \n\n\nprint(fullS(sL, 0, 0))']
['Runtime Error', 'Accepted']
['s698837034', 's300511201']
[9260.0, 9084.0]
[29.0, 33.0]
[980, 975]
p02683
u722148122
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 = input().split()\nC, A = [], []\nfor _ in range(N):\n tmp = [int(a) for a in input().split()]\n C.append(tmp[0])\n A.append(tmp[1:])\n\nmi = 1 << 100\nfor binary in range(1 << N):\n B = [0] * M\n c = 0\n for i in range(N):\n if binary >> N & 1:\n c += C[i]\n for j in range(M):\n B[j] += A[i][j]\n if min(B) >= X:\n mi = min(c, mi)\nprint(mi if mi < 1 << 99 else -1)\n', 'N, M, X = map(int, input().split())\nC, A = [], []\nfor _ in range(N):\n tmp = [int(a) for a in input().split()]\n C.append(tmp[0])\n A.append(tmp[1:])\n\nmi = 1 << 100\nfor binary in range(1 << N):\n B = [0] * M\n c = 0\n for i in range(N):\n if binary >> i & 1:\n c += C[i]\n for j in range(M):\n B[j] += A[i][j]\n if min(B) >= X:\n mi = min(c, mi)\nprint(mi if mi < 1 << 99 else -1)\n']
['Runtime Error', 'Accepted']
['s161118337', 's582845354']
[9164.0, 9216.0]
[23.0, 82.0]
[430, 440]
p02683
u723583932
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())\nA=[]\nfor i in range(n):\n ca=list(map(int,input().split()))\n A.append(ca)\nans=10**7\n\nfor i in range(2**n):\n tmp=[0]*m\n cost=0\n for j in range(n):\n if (1<<j)&i:\n cost+=A[j][0]\n for k in range(m):\n tmp[k]+=A[j][k+1]\n for l in range(m):\n if tmp[l]<x:\n break\n ans=min(ans,cost)\nif ans==10**7:\n ans=-1\nprint(ans)\n\n\n', 'import sys\nn,m,x=map(int,input().split())\nA=[]\nfor i in range(n):\n ca=list(map(int,input().split()))\n A.append(ca)\nans=10**7\n\nfor i in range(2**n):\n tmp=[0]*m\n cost=0\n for j in range(n):\n if (1<<j)&i:\n cost+=A[j][0]\n for k in range(m):\n tmp[k]+=A[j][k+1]\n check=True\n for l in range(m):\n if tmp[l]<x:\n check=False\n break\n #else:\n if check:\n ans=min(ans,cost)\n \nif ans==10**7:\n ans=-1\nprint(ans)\n\n\n']
['Wrong Answer', 'Accepted']
['s651781710', 's643974190']
[9204.0, 9132.0]
[85.0, 85.0]
[624, 772]
p02683
u725993280
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)]\n\nans = float(\'inf\')\n\nprint(c)\n\nfor i in range(2**n):\n hold = [0] * (m+1)\n for j in range(n):\n if (i >> j) & 1:\n for k in range(m+1):\n hold[k] += c[j][k]\n if min(hold[1:]) >= x : \n ans = min(ans,hold[0])\n\nif ans != float(\'inf\'):\n print(ans)\nelse:\n print("-1")\n\n', 'n,m,x = map(int,input().split())\nc = [list(map(int,input().split())) for i in range(n)]\n\nans = float(\'inf\')\n\nprint(c)\n\nfor i in range(2**n):\n hold = [0] * (m+1)\n for j in range(n):\n if(i >> j) and 1:\n for k in range(m+1):\n hold[k] += c[j][k]\n if min(hold[1:]) >= x : \n ans = min(ans,hold[0])\n\nif ans != float(\'inf\'):\n print(ans)\nelse:\n print("-1")', 'n,m,x = map(int,input().split())\nc = [list(map(int,input().split())) for i in range(n)]\n\nans = float(\'inf\')\n\nfor i in range(2**n):\n hold = [0] * (m+1)\n for j in range(n):\n if (i >> j) & 1:\n for k in range(m+1):\n hold[k] += c[j][k]\n if min(hold[1:]) >= x : \n ans = min(ans,hold[0])\n\nif ans != float(\'inf\'):\n print(ans)\nelse:\n print("-1")\n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s319354719', 's493617707', 's867664647']
[9068.0, 9156.0, 9204.0]
[86.0, 132.0, 82.0]
[524, 523, 514]
p02683
u727980193
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()))\nAC=[]\nC=[]\nA=[]\nfor n in range(N):\n AC.append(list(map(int,input().split())))\n C.append(AC[0])\n A.append(AC[1:])\nans=0\nfor n in range(2**N):\n total=0\n und=[0]*M\n for j in range(N):\n if n >> j & 1:\n total+=C[j]\n for m in range(M):\n und[m]+=A[j][m]\n if X <= min(und):\n ans=total\nif ans==0:\n print(-1)\nelse:\n print(ans)\n ', 'N,M,X=list(map(int,input().split()))\n\nC=[]\nA=[]\nfor n in range(N):\n AC=list(map(int,input().split()))\n C.append(AC[0])\n A.append(AC[1:])\nans=10**9\n\nfor n in range(2**N):\n total=0\n und=[0]*M\n for j in range(N):\n if n >> j & 1:\n total+=C[j]\n for m in range(M):\n und[m]+=A[j][m]\n if X <= min(und):\n ans=min(total,ans)\nif ans==10**9:\n print(-1)\nelse:\n print(ans)']
['Runtime Error', 'Accepted']
['s518673835', 's154996735']
[9204.0, 9164.0]
[21.0, 80.0]
[390, 390]
p02683
u729938879
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())\ncosts = []\nunderstnding = []\nans = 10 ** 20\n\nfor _ in range(n):\n tmp = list(map(int, input().split()))\n costs.append(tmp[0])\n understnding.append(tmp[1:])\n \ncosts = np.array(costs)\nunderstnding = np.array(understnding)\n\nfor i in range(2**n):\n row = str(bin(i)).split("0b")[1]\n row = \'0\'*(n - len(row_tmp))+row_tmp\n one_index = [j for j in range(len(row)) if row[j] =="1"]\n cost_sum = np.sum(costs[one_index])\n under_sum = np.sum(understnding[one_index], axis=0)\n if np.all(under_sum >= x) and cost_sum < ans:\n ans = cost_sum\n \nif ans = 10 ** 20:\n print(-1)\nelse\n print(ans)', 'from itertools import combinations\nimport numpy as np\nn,m,x = map(int, input().split())\ncosts = []\nunderstnding = []\nans = 10 ** 20\n\nfor _ in range(n):\n tmp = list(map(int, input().split()))\n costs.append(tmp[0])\n understnding.append(tmp[1:])\n \ncosts = np.array(costs)\nunderstnding = np.array(understnding)\n\nfor i in range(2**n):\n row = str(bin(i)).split("0b")[1]\n row = \'0\'*(n - len(row_tmp))+row_tmp\n one_index = [j for j in range(len(row)) if row[j] =="1"]\n cost_sum = np.sum(costs[one_index])\n under_sum = np.sum(understnding[one_index], axis=0)\n if np.all(under_sum >= x) and cost_sum < ans:\n ans = cost_sum\n \nif ans == 10 ** 20:\n print(-1)\nelse:\n print(ans)', 'import numpy as np\nn,m,x = map(int, input().split())\ncosts = []\nunderstnding = []\nans = 10 ** 20\n\nfor _ in range(n):\n tmp = list(map(int, input().split()))\n costs.append(tmp[0])\n understnding.append(tmp[1:])\n \ncosts = np.array(costs)\nunderstnding = np.array(understnding)\n\nfor i in range(1, 2**n):\n row = str(bin(i)).split("0b")[1]\n row = \'0\'*(n - len(row))+row\n one_index = [j for j in range(len(row)) if row[j] =="1"]\n cost_sum = np.sum(costs[one_index])\n under_sum = np.sum(understnding[one_index], axis=0)\n if np.all(under_sum >= x) and cost_sum < ans:\n ans = cost_sum\n \nif ans == 10 ** 20:\n print(-1)\nelse:\n print(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s013899994', 's843423107', 's842971150']
[8936.0, 27168.0, 27404.0]
[27.0, 117.0, 193.0]
[707, 709, 669]
p02683
u745861782
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()))\nlists = []\nresult_price = 0\nexisted = False\n\nfor i in range(n):\n lists.append(list(map(int, input().split())))\n\nfor i in range(n):\n result_price += lists[i][0]\nfor i in range(1 << n):\n flag = True\n scores = [0] * m\n tmp_price = 0\n for j in range(n):\n if i & (1 << j):\n for k in range(m):\n scores[k] += lists[j][k+1]\n tmp_price += lists[j][0]\n for l in range(m):\n if scores[l] < x:\n flag = False\n break\n if flag and (result_price > tmp_price):\n print(i)\n existed = True\n result_price = tmp_price\nif existed:\n print(result_price)\nelse:\n print(-1)', 'n, m, x = list(map(int, input().split()))\nlists = []\nresult_price = 0\nexisted = False\n\nfor i in range(n):\n lists.append(list(map(int, input().split())))\n\nfor i in range(1 << n):\n flag = True\n scores = [0] * m\n tmp_price = 0\n for j in range(n):\n if i & (1 << j):\n for k in range(m):\n scores[k] += lists[j][k+1]\n tmp_price += lists[j][0]\n for l in range(m):\n if scores[l] < x:\n flag = False\n break\n if flag and (result_price > tmp_price or result_price == 0):\n existed = True\n result_price = tmp_price\nif existed:\n print(result_price)\nelse:\n print(-1)']
['Wrong Answer', 'Accepted']
['s943903944', 's329640647']
[9208.0, 9236.0]
[84.0, 84.0]
[638, 597]
p02683
u749742659
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\nx,m,n = map(int, input().split())\n\nacq2 = 0\ncost = []\nskill = []\nfor i in range(n):\n ca = list(map(int, input().split()))\n cost.append(ca[0])\n skill.append(np.array(ca[1:]))\n\ncostmin = 0\nfor a in range(n):\n costmin += cost[a]\n\ndef tworaw(num):\n if (num % 2 == 0):\n return 0\n else:\n return 1\n\nfor j in range(2**n):\n buy = []\n cost_temp = 0\n skill_temp = np.zeros(m)\n acq = 1\n nn = j\n for k in range(n):\n buy.append(tworaw(nn))\n nn = nn // 2\n print(buy)\n\n\n for l in range(n):\n if (buy[l] == 1):\n cost_temp += cost[l]\n skill_temp += skill[l]\n \n for b in range(m):\n if (skill_temp[b] < x):\n acq = 0\n break\n \n\n if (acq == 1):\n acq2 = 1\n if (cost_temp < costmin):\n costmin = cost_temp\n\n\nif (acq2 == 1):\n print(int(costmin))\nelse:\n print('-1')", "import numpy as np\nx,m,n = map(int, input().split())\n\nacq2 = 0\ncost = []\nskill = []\nfor i in range(n):\n ca = list(map(int, input().split()))\n cost.append(ca[0])\n skill.append(np.array(ca[1:]))\n\ncostmin = 0\nfor a in range(n):\n costmin += cost[a]\n\ndef tworaw(num):\n if (num % 2 == 0):\n return 0\n else:\n return 1\n\nfor j in range(2**n):\n buy = []\n cost_temp = 0\n skill_temp = np.zeros(m)\n acq = 1\n nn = j\n for k in range(n):\n buy.append(tworaw(nn))\n nn = nn // 2\n\n for l in range(n):\n if (buy[l] == 1):\n cost_temp += cost[l]\n skill_temp += skill[l]\n \n for b in range(m):\n if (skill_temp[b] < x):\n acq = 0\n break\n \n\n if (acq == 1):\n acq2 = 1\n if (cost_temp < costmin):\n costmin = cost_temp\n\n\nif (acq2 == 1):\n print(int(costmin))\nelse:\n print('-1')", "import numpy as np\nx,m,n = map(int, input().split())\n\nacq2 = 0\ncost = []\nskill = []\nfor i in range(n):\n ca = list(map(int, input().split()))\n cost.append(ca[0])\n skill.append(np.array(ca[1:]))\n\ncostmin = 0\nfor a in range(n):\n costmin += cost[b]\n\ndef tworaw(num):\n if (num % 2 == 0):\n return 0\n else:\n return 1\n\nfor j in range(2**n):\n buy = []\n cost_temp = 0\n skill_temp = np.zeros(m)\n acq = 1\n nn = n\n for k in range(n):\n buy.append(tworaw(nn))\n nn = nn // 2\n for l in range(n):\n if (buy[l] = 1):\n cost_temp += cost[l]\n skill_temp += skill[l]\n \n for b in range(m):\n if (skill[a] < x):\n acq = 0\n break\n \n if (acq == 1):\n acq2 = 1\n if (cost_temp < costmin):\n costmin = cost_temp\n\n\nif (acq2 == 1):\n print(int(costmin))\nelse:\n print('-1')", "import numpy as np\nn,m,x = map(int, input().split())\n\nacq2 = 0\ncost = []\nskill = []\nfor i in range(n):\n ca = list(map(int, input().split()))\n cost.append(ca[0])\n skill.append(np.array(ca[1:]))\n\ncostmin = 0\nfor a in range(n):\n costmin += cost[a]\n\ndef tworaw(num):\n if (num % 2 == 0):\n return 0\n else:\n return 1\n\nfor j in range(2**n):\n buy = []\n cost_temp = 0\n skill_temp = np.zeros(m)\n acq = 1\n nn = j\n for k in range(n):\n buy.append(tworaw(nn))\n nn = nn // 2\n\n for l in range(n):\n if (buy[l] == 1):\n cost_temp += cost[l]\n skill_temp += skill[l]\n \n for b in range(m):\n if (skill_temp[b] < x):\n acq = 0\n break\n \n\n if (acq == 1):\n acq2 = 1\n if (cost_temp < costmin):\n costmin = cost_temp\n\n\nif (acq2 == 1):\n print(int(costmin))\nelse:\n print('-1')"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s057186673', 's108245538', 's432158944', 's210338542']
[27076.0, 27072.0, 9072.0, 27184.0]
[108.0, 112.0, 23.0, 171.0]
[926, 910, 902, 910]
p02683
u752500421
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()))\n\nc_list = []\na_matrix = []\n\nfor i in range(n):\n items = list(map(int, input().split()))\n c_list.append(items[0])\n a_matrix.append(items[1:])\n\nmin_cost = 1000000 * (n+1)\n\nfor i in range(2^n):\n cost = 0\n skill_sum = [0 for _ in range(m)]\n bit_pattern = format(i, \'0\' + str(n) + \'b\')[::-1]\n for i, a_line in enumerate(a_matrix):\n if bit_pattern[i] == "1":\n cost += c_list[i]\n for j, a in enumerate(a_line):\n skill_sum[j] += a\n \n if all(map(lambda skill_s: skill_s >= x, skill_sum)) and cost < min_cost:\n min_cost = cost\n\nif min_cost >= 1000000 * (n+1):\n print(-1)\nelse:\n print(min_cost)', 'n, m, x = list(map(int, input().split()))\n\nc_list = []\na_matrix = []\n\nfor i in range(n):\n items = list(map(int, input().split()))\n c_list.append(items[0])\n a_matrix.append(items[1:])\n\nmin_cost = 1000000 * (n+1)\n\nfor i in range(2**n):\n cost = 0\n skill_sum = [0 for _ in range(m)]\n bit_pattern = format(i, \'0\' + str(n) + \'b\')[::-1]\n for i, a_line in enumerate(a_matrix):\n if bit_pattern[i] == "1":\n cost += c_list[i]\n for j, a in enumerate(a_line):\n skill_sum[j] += a\n \n if all(map(lambda skill_s: skill_s >= x, skill_sum)) and cost < min_cost:\n min_cost = cost\n\nif min_cost >= 1000000 * (n+1):\n print(-1)\nelse:\n print(min_cost)']
['Wrong Answer', 'Accepted']
['s962600788', 's446544784']
[9248.0, 9132.0]
[23.0, 74.0]
[709, 710]
p02683
u756607246
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\ndef main():\n N, M, X = map(int, input().split())\n Cs = [list(map(int, input().split())) for _ in range(N)]\n mi = 100000000000000000000 #->float("inf")\n for i in range(1<<N):\n lis = [0] * (M+1)\n for j in range(N):\n if i & (1<<j) == 0:\n continue\n for k in range(M):\n lis[k] += Cs[j][k]\n if all(v>=X for v in lis[1:]):\n mi = min(lis[0], mi)\n\n return -1 if mi == 100000000000000000000 else mi\n\nif __name__ == \'__main__\':\n #start = time.time()\n print(main())\n #elapsed_time = time.time() - start\n ', '\n\ndef main():\n N, M, X = map(int, input().split())\n Cs = [list(map(int, input().split())) for _ in range(N)]\n mi = 100000000000000000000 #->float("inf")\n for i in range(1<<N):\n lis = [0] * (M+1)\n for j in range(N):\n if i & (1<<j) == 0:\n continue\n for k in range(M+1):\n lis[k] += Cs[j][k]\n if all(v>=X for v in lis[1:]):\n mi = min(lis[0], mi)\n\n return -1 if mi == 100000000000000000000 else mi\n\nif __name__ == \'__main__\':\n #start = time.time()\n print(main())\n #elapsed_time = time.time() - start\n ']
['Wrong Answer', 'Accepted']
['s127172697', 's203548021']
[9164.0, 9216.0]
[70.0, 74.0]
[681, 683]
p02683
u760446276
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())\nc=[0]*n\na=[[0 for i in range(m)] for j in range(n)]\nprint(a)\ncurrent_skill=[0]*m\nINF=9999999\nmin_money=INF\n\n\nfor i in range(n):\n tmp=list(map(int,input().split()))\n c[i]=tmp[0]\n a[i]=tmp[1:]\n\ncurrent_money=0\n\nfor i in range(1 << n):\n bug=[]\n #print('current_money=',current_money)\n #print('current_skill=',current_skill)\n for j in range(n):\n if (i>>j) &1:\n bug.append(j)\n current_skill=[0]*m\n current_money=0\n for chosen_set_num in bug:\n current_money+=c[chosen_set_num]\n for each_book_num in range(m):\n current_skill[each_book_num]+=a[chosen_set_num][each_book_num]\n \n\n if all(status >=x for status in current_skill ):\n min_money=min(min_money,current_money)\n continue\nif min_money==INF:\n min_money=-1\nprint(min_money)\n", 'import itertools\nn,m,x=map(int,input().split())\nc=[0]*n\na=[[0 for i in range(m)] for j in range(n)]\ncurrent_skill=[0]*m\nINF=9999999\nmin_money=INF\n\n\nfor i in range(n):\n tmp=list(map(int,input().split()))\n c[i]=tmp[0]\n a[i]=tmp[1:]\n\ncurrent_money=0\n\nfor i in range(1 << n):\n bug=[]\n for j in range(n):\n if (i>>j) &1:\n bug.append(j)\n current_skill=[0]*m\n current_money=0\n for chosen_set_num in bug:\n current_money+=c[chosen_set_num]\n for each_book_num in range(m):\n current_skill[each_book_num]+=a[chosen_set_num][each_book_num]\n \n\n if all(status >=x for status in current_skill ):\n min_money=min(min_money,current_money)\n continue\nif min_money==INF:\n min_money=-1\nprint(min_money)\n']
['Wrong Answer', 'Accepted']
['s343979290', 's643763628']
[9236.0, 9196.0]
[98.0, 98.0]
[885, 790]
p02683
u761062383
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\n\nn, m, x = map(int, input().split())\ncalist = []\nfor i in range(n):\n ca = list(map(int, input().split()))\n calist.append(ca)\n\n# print(n, m, x, calist)\n\n\nfor j in range(m):\n sum = 0\n for i in range(n):\n sum += calist[i][j + 1]\n if sum < x:\n print(-1)\n exit()\n\ncalist = np.array(calist)\ndp = float('inf')\n\nfor comb in range(1, m + 1):\n sc = itertools.combinations(calist, comb)\n sum = 0\n a = np.array([0 for _ in range(m)])\n for ca in sc:\n sum += ca[0]\n a += ca[1:]\n if False not in (a > x) and sum < dp:\n dp = sum\n\nprint(dp)\n", 'import unittest\nfrom io import StringIO\nimport sys\n\n\ndef resolve():\n n, m, x = [int(i) for i in input().split()]\n cc = []\n aa = []\n for comb in range(n):\n c, *a = [int(comb) for comb in input().split()]\n cc.append(c)\n aa.append(a)\n\n ans = float(\'inf\')\n for comb in range(2**n):\n sum = 0\n xx = [0] * m\n for i in range(n):\n if (comb >> i) & 1:\n sum += cc[i]\n for j in range(m):\n xx[j] += aa[i][j]\n for tx in xx:\n if tx < x:\n break\n else:\n ans = min(ans, sum)\n\n if ans == float(\'inf\'):\n print(-1)\n else:\n print(ans)\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\nif __name__ == "__main__":\n # unittest.main()\n resolve()\n']
['Runtime Error', 'Accepted']
['s264551907', 's944544193']
[27232.0, 16284.0]
[106.0, 102.0]
[639, 1665]
p02683
u764956288
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\ndef main():\n N, M, X = map(int, input().split())\n\n books = np.array([list(map(int, input().split())) for _ in range(N)])\n\n min_total_cost = 10**9\n\n for i in range(2**N):\n to_read_indexes = np.array(list(str(i)), dtype=int)\n to_read_books = books[to_read_indexes, :]\n total_cost = to_read_books[:, 0].sum()\n increased_levels = to_read_books[:, 1:].sum(axis=0)\n\n if min(increased_levels) >= X:\n min_total_cost = min(min_total_cost, total_cost)\n\n if min_total_cost == 10**9:\n print(\'-1\')\n else:\n print(min_total_cost)\n\n\nif __name__ == "__main__":\n main()\n', 'def main():\n N, M, X = map(int, input().split())\n\n books = [list(map(int, input().split())) for _ in range(N)]\n\n min_total_cost = 10**9\n\n for i in range(2**N):\n total_cost = 0\n learned = [0] * M\n\n for j in range(N):\n if (i >> j) & 1:\n cost, points = books[j]\n total_cost += cost\n \n learned = [x + y for x, y in zip(learned, points)]\n\n if min(learned) >= X:\n min_total_cost = min(min_total_cost, total_cost)\n\n if min_total_cost == 10**9:\n print(\'-1\')\n else:\n print(min_total_cost)\n\n\nif __name__ == "__main__":\n main()\n', 'def main():\n N, M, X = map(int, input().split())\n\n books = [list(map(int, input().split())) for _ in range(N)]\n\n min_total_cost = 10**9\n\n for i in range(2**N):\n total_cost = 0\n learned = [0] * M\n\n for j in range(N):\n if (i >> j) & 1:\n cost, *points = books[j]\n total_cost += cost\n\n learned = [x + y for x, y in zip(learned, points)]\n\n if min(learned) >= X:\n min_total_cost = min(min_total_cost, total_cost)\n\n if min_total_cost == 10**9:\n print(\'-1\')\n else:\n print(min_total_cost)\n\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s197869219', 's414679803', 's859760836']
[27272.0, 9204.0, 9220.0]
[150.0, 19.0, 56.0]
[654, 662, 647]
p02683
u767664985
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())\nA = [list(map(int, input().split())) for _ in range(N)]\nans = float("inf")\n\nfor now in product(range(2), N):\n res = 0\n An = [0 for _ in range(M)]\n for n in range(N):\n if now[n] == 1:\n res += A[n][0]\n An = [An[j] + A[n][j+1] for j in range(M)]\n if min(An) >= X:\n ans = min(ans, res)\n\nif ans == float("inf"):\n print(-1)\nelse:\n print(ans)\n', 'from itertools import product\n\nN, M, X = map(int, input().split())\nA = [list(map(int, input().split())) for _ in range(N)]\nans = float("inf")\n\nfor now in product(range(2), repeat=N):\n res = 0\n An = [0 for _ in range(M)]\n for n in range(N):\n if now[n] == 1:\n res += A[n][0]\n An = [An[j] + A[n][j+1] for j in range(M)]\n if min(An) >= X:\n ans = min(ans, res)\n\nif ans == float("inf"):\n print(-1)\nelse:\n print(ans)\n']
['Runtime Error', 'Accepted']
['s835648344', 's529040694']
[9112.0, 9224.0]
[23.0, 72.0]
[457, 464]
p02683
u767995501
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\n# input\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)\n\nif ans == INF:\n ans = -1\n\nprint(ans)\n', '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: 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)\n\nif ans == INF:\n ans = -1\n\nprint(ans)\n\n\n']
['Wrong Answer', 'Accepted']
['s906627660', 's988785204']
[9228.0, 9244.0]
[72.0, 88.0]
[598, 582]
p02683
u768256617
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())\nnedan=[]\ngrade=[]\nans=-1\nfor i in range(n):\n s=list(map(int,input().split())) \n nedan.append(s.pop(0))\n grade.append(s)\n\n#print(grade)\n\nfor i in range(2**n):\n shopping=[]\n total_grade=[]\n for j in range(n):\n if (( i >> j ) & 1):\n shopping.append(nedan[j])\n print(nedan[j])\n total_grade.append(grade[j])\n print(grade[j])\n\n t=sum(shopping)\n print(t)\n print(shopping)\n print(total_grade)\n sum_grade=[]\n for j in range(m):\n s=0\n for k in range(len(total_grade)):\n s+=total_grade[k][j]\n sum_grade.append(s)\n\n if sum_grade >=[x]*len(total_grade):\n ans=t\n break\nprint(t)\nif ans==-1:\n print(-1)\n\nelse:\n print(ans)', "import sys\nimport numpy as np\nsys.setrecursionlimit(10**8)\n\ndef dfs(i,a,value):\n global ans\n if i==n:\n if all(a[i]>=x for i in range(m)):\n ans=min(ans,value)\n\n else:\n ans=-1\n\n else:\n dfs(i+1,a,value)\n dfs(i+1,a+np.array(pc[i][1:]),value+pc[i][0])\n\n\nans=float('inf')\nn,m,x=map(int,input().split())\npc=[]\nfor i in range(n):\n s=list(map(int,input().split()))\n pc.append(s)\n\ndfs(0,np.array([0]*(m)),0)\nprint(ans)", 'n,m,x=map(int,input().split())\nnedan=[]\ngrade=[]\ninf=12*10**6\nfor i in range(n):\n s=list(map(int,input().split())) \n nedan.append(s.pop(0))\n grade.append(s)\n\n#print(grade)\n\nfor i in range(2**n):\n shopping=[]\n total_grade=[]\n for j in range(n):\n if (( i >> j ) & 1):\n shopping.append(nedan[j])\n total_grade.append(grade[j])\n\n t=sum(shopping)\n #print(t)\n #print(shopping)\n #print(total_grade)\n sum_grade=[]\n for j in range(m):\n s=0\n for k in range(len(total_grade)):\n s+=total_grade[k][j]\n sum_grade.append(s)\n print(sum_grade)\n\n ans_t=[]\n if all(j>=x for j in sum_grade):\n ans_t.append(t)\n\nprint(ans_t) \nans=min(ans_t)\n\nif min(ans,inf)==ans:\n print(ans)\n\nelse:\n print(-1)', "def mi(): return map(int,input().split())\ndef lmi(): return list(map(int,input().split()))\ndef ii(): return int(input())\ndef isp(): return input().split()\n\nimport sys\nimport numpy as np\n\nsys.setrecursionlimit(10**8)\nn,m,x=mi()\nlist_ans=[]\nfor i in range(n):\n c_=lmi()\n list_ans.append(c_)\n\nans=float('inf')\n\ndef dfs(i,suma,count):\n global ans\n if i==n:\n \n if np.all(count>=x):\n ans=min(ans,suma)\n return ans\n\n else:\n dfs(i+1,suma,count)\n dfs(i+1,suma+list_ans[i][0],count+np.array(list_ans[i][1:]))\n\ndfs(0,0,np.array([0]*m))\nif ans==float('inf'):\n print(-1)\n exit()\n \nelse:\n print(ans)"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s195188725', 's493517952', 's952117532', 's987677490']
[9256.0, 27244.0, 9264.0, 27284.0]
[22.0, 134.0, 141.0, 144.0]
[709, 435, 736, 616]
p02683
u770076823
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 = []\nresult = -1\n\nfor i in range(N):\n tmp = list(map(int, input().split()))\n C.append(tmp[0])\n A.append(tmp[1:])\n\nfor n in range(1 << N-1):\n Cn = 0\n skill = [0] * M\n for i in range(N):\n if (n >> i) & 1 == 1:\n Cn += C[i]\n for j in range(M):\n skill[j] += A[i][j]\n\n if all(x >= X for x in skill):\n if result == -1:\n result = Cn\n else:\n result = min(result, Cn)\n\nprint(result)\n', 'N, M, X = map(int, input().split())\nC = []\nA = []\nresult = -1\n\nfor i in range(N):\n tmp = list(map(int, input().split()))\n C.append(tmp[0])\n A.append(tmp[1:])\n\nfor n in range(1 << N):\n Cn = 0\n skill = [0] * M\n for i in range(N):\n if (n >> i) & 1 == 1:\n Cn += C[i]\n for j in range(M):\n skill[j] += A[i][j]\n\n if all(x >= X for x in skill):\n if result == -1:\n result = Cn\n else:\n result = min(result, Cn)\n\nprint(result)\n']
['Wrong Answer', 'Accepted']
['s236295432', 's047271402']
[9192.0, 9208.0]
[50.0, 81.0]
[519, 517]
p02683
u771007149
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.
['#ABC167-C\nimport numpy as np\nflg = True\nn,m,x = map(int,input().split())\nalgo = []\ntmp = []\nfor _ in range(n):\n algo.append(list(map(int,input().split())))\n \nbook = list(itertools.product([0,1],repeat=n))\nabi = [0 for _ in range(m)]\n\nfor pattern in book:\n \n abi = [0 for _ in range(m)]\n money = 0\n flg = True\n \n for i in range(len(pattern)):\n for j in range(m):\n abi[j] += algo[i][j+1] * pattern[i]\n money += algo[i][0] * pattern[i]\n \n abi_min = [p for p in abi if p < x]\n \n if len(abi_min) != 0:\n flg = False\n if flg:\n print(money)\n tmp.append(money)\n\nif len(tmp) > 0:\n print(min(tmp))\nelse:\n print(-1)\n \n \n \n \n \n ', '#C\nimport numpy as np\nflg = True\nn,m,x = map(int,input().split())\nalgo = []\nfor _ in range(n):\n algo.append(list(map(int,input().split())))\n \n\nalgo_n = np.array(algo)\nalgo_sum = algo_n.sum(axis=0)\ngokei = algo_sum.tolist()\nmoney = gokei[0]\ngokei = gokei[1:]\n\n\nfor i in range(m):\n if gokei[i] < x:\n flg = False\n print(-1)\n break\n\nalgo.sort(key= lambda x:x[0],reverse=True)\n\n\n\n\ndef hikizan(lst1,lst2):\n#lst1 - lst2\n for i in range(len(lst1)):\n l1 = lst1[i]\n l2 = lst2[i]\n l1 -= l2\n lst1[i] = l1\n \n return lst1\n\nif flg:\n for i in range(n):\n flg = True\n for j in range(1,m+1):\n if gokei[j-1] - algo[i][j] < x:\n flg = False\n pass\n if flg:\n gokei = hikizan(gokei,algo[i][1:])\n money -= algo[i][0]\n \nprint(money)\n\n\n ', '#ABC167-C\nimport itertools\nflg = True\nn,m,x = map(int,input().split())\nalgo = []\ntmp = []\nfor _ in range(n):\n algo.append(list(map(int,input().split())))\n \nbook = list(itertools.product([0,1],repeat=n))\nabi = [0 for _ in range(m)]\n\nfor pattern in book:\n \n abi = [0 for _ in range(m)]\n money = 0\n flg = True\n \n for i in range(len(pattern)):\n for j in range(m):\n abi[j] += algo[i][j+1] * pattern[i]\n money += algo[i][0] * pattern[i]\n \n abi_min = [p for p in abi if p < x]\n \n if len(abi_min) != 0:\n flg = False\n if flg:\n print(money)\n tmp.append(money)\n\nif len(tmp) > 0:\n print(min(tmp))\nelse:\n print(-1)\n \n \n \n \n \n ', 'import itertools\nn,m,x = map(int,input().split())\nbook = []\nfor _ in range(n):\n book.append(list(map(int,input().split())))\n\nbuy = list(itertools.product([0,1],repeat=n))\n\nmoney = []\n\nfor i in range(len(buy)):\n algo = [0 for _ in range(m)]\n money_tmp = 0\n \n for j in range(len(buy[i])):\n for k in range(m):\n algo[k] += book[j][k+1] * buy[i][j]\n money_tmp += book[j][0]*buy[i][j]\n #print(money_tmp)\n if min(algo) >= x:\n money.append(money_tmp)\n \nif len(money) > 0: \n print(min(money))\nelse:\n print(-1)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s170243633', 's203773750', 's954700192', 's977784194']
[27140.0, 9096.0, 9756.0, 9644.0]
[103.0, 22.0, 171.0, 183.0]
[784, 917, 782, 583]
p02683
u773440446
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 = [list(map(int,input().split())) for i in range(N)]\nbag = []\n\nfor i in range(2**N):\n temp = []\n job = [0] * M\n for s in range(N):\n if (i>>s)&1:\n temp.append(s)\n for j in range(M):\n job[j] += item[s][j+1]\n for s in range(len(job)):\n if job[s]<X:\n break\n else:\n ans = 0\n for s in temp:\n ans += item[s][0]\n bag.append(ans)\nprint(min(bag) if len(bag)>=1 else -1) ', '# coding: utf-8\nN,M,X = map(int,input().split())\nitem = [list(map(int,input().split())) for i in range(N)]\nbag = []\n\nfor i in range(2**N):\n temp = []\n job = [0] * M\n for s in range(N):\n if (i>>s)&1:\n temp.append(s)\n for j in range(M):\n job[j] += item[s][j+1]\n for s in range(len(job)):\n if job[s]<X:\n break\n else:\n ans = 0\n for s in temp:\n ans += item[s][0]\n bag.append(ans)\nprint(min(bag) if len(bag)>=1 else -1) \n']
['Runtime Error', 'Accepted']
['s454874328', 's147880941']
[9132.0, 9196.0]
[25.0, 91.0]
[447, 463]
p02683
u773686010
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.
['#https://atcoder.jp/contests/abc167/tasks/abc167_c C - Skill Up\nimport numpy as np\nfrom itertools import combinations\nN,M,X=list(map(int,input().split()))\nbook_dict={}\nfor i in range(M):\n book_dict[i] = list(map(int,input().split()))\n\nanswer = (10**5*12)+1\nfor i in range(M,0,-1):\n for v in combinations(book_dict.keys(), i):\n search_book = list(map(lambda x:book_dict[x],list(v)))\n sum_search_book = np.array(np.sum(search_book,axis = 0))\n if (np.count_nonzero(sum_search_book[1:] >= X) == N) and sum_search_book[0] < answer:\n answer = sum_search_book[0]\n print(ansew)\n \n\n \nif answer == (10**5*12)+1:\n answer = -1\n\nprint(answer)\n', '#https://atcoder.jp/contests/abc167/tasks/abc167_c C - Skill Up\nimport numpy as np\nimport math\nfrom itertools import combinations\nN,M,X=list(map(int,input().split()))\nbook_dict={}\nfor i in range(N):\n book_dict[i] = list(map(int,input().split()))\n\nanswer = (10**5*12)+1\nfor i in range(N,0,-1):\n current_book_number=0 \n for v in combinations(book_dict.keys(), i):\n \n search_book = list(map(lambda x:book_dict[x],list(v)))\n sum_search_book = np.array(np.sum(search_book,axis = 0))\n if (np.count_nonzero(sum_search_book[1:] >= X) == M) and sum_search_book[0] < answer:\n answer = sum_search_book[0]\n else:\n current_book_number+=1\n \n if current_book_number==int(math.factorial(N)/(math.factorial(i)*math.factorial(N-i))):\n break: \n \nif answer == (10**5*12)+1:\n answer = -1\n\nprint(answer)\n', '#https://atcoder.jp/contests/abc167/tasks/abc167_c C - Skill Up\nimport numpy as np\nimport math\nfrom itertools import combinations\nN,M,X=list(map(int,input().split()))\nbook_dict={}\nfor i in range(N):\n book_dict[i] = list(map(int,input().split()))\n\nanswer = (10**5*12)+1\nfor i in range(N,0,-1):\n current_book_number=0 \n for v in combinations(book_dict.keys(), i):\n \n search_book = list(map(lambda x:book_dict[x],list(v)))\n sum_search_book = np.array(np.sum(search_book,axis = 0))\n if (np.count_nonzero(sum_search_book[1:] >= X) == M) and sum_search_book[0] < answer:\n answer = sum_search_book[0]\n else:\n current_book_number+=1\n \n if current_book_number==int(math.factorial(N)/(math.factorial(i)*math.factorial(N-i))):\n break \n \nif answer == (10**5*12)+1:\n answer = -1\n\nprint(answer)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s359306657', 's497353754', 's325347236']
[27292.0, 9028.0, 27256.0]
[170.0, 25.0, 174.0]
[765, 1111, 1110]
p02683
u779728630
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.
['big_int = 10 ** 9\n\nN, M, X = map(int, input().split())\n\nL = []\nfor i in range(N):\n L.insert( tuple(map(int, input().split())) )\n\ndef foo(i):\n T = [0 for j in range(M+1)]\n for j in range(N):\n for k in range(M+1):\n T[k] += L[j][k] * (i%2)\n i //= 2\n for k in range(1,M+1):\n if T[k] < X:\n return big_int\n return T[0]\n \nans = big_int\n\nfor i in range(2**N):\n ans = min(ans, foo(i))\n \nif ans == big_int:\n print(-1)\nelse:\n print(ans)', 'big_int = 10 ** 9\n\nN, M, X = map(int, input().split())\n\nL = [0 for i in range(N)]\nfor i in range(N):\n L[i] = tuple(map(int, input().split()))\n\ndef foo(i):\n t = i\n T = [0 for j in range(M+1)]\n for j in range(N):\n for k in range(M+1):\n T[k] += L[j][k] * (t%2)\n t //= 2\n for k in range(1,M+1):\n if T[k] < X:\n return big_int\n return T[0]\n \nans = big_int\n\nfor i in range(2**N):\n ans = min(ans, foo(i))\n \nif ans == big_int:\n print(-1)\nelse:\n print(ans)']
['Runtime Error', 'Accepted']
['s413801570', 's051072860']
[9236.0, 9240.0]
[24.0, 123.0]
[456, 476]
p02683
u797550216
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 = [list(map(int,input().split())) for i in range(n)]\n\ndef generate_n_bit(n):\n bins= []\n for i in range(2**n):\n bins.append(list(str(format(i,'b').zfill(n))))\n \n return bins\n\nmin_price = 10**9\nbins = generate_n_bit(10)\ndel bins[0]\n\nfor bin in bins:\n a = [0 for k in range(m)]\n price = 0\n for i in range(n):\n if bin[i] == '1':\n for j in range(m):\n a[j] += l[i][j+1]\n \n price += l[i][0]\n \n \n \n if min(a) >= x:\n min_price = min(price, min_price)\n print(min_price)\n\n\nprint(min_price)\n\n", "n, m, x = map(int,input().split())\nl = [list(map(int,input().split())) for i in range(n)]\n\ndef generate_n_bit(n):\n bins= []\n for i in range(2**n):\n bins.append(list(str(format(i,'b').zfill(n))))\n \n return bins\n\nmin_price = 10**9\nbins = generate_n_bit(n)\nbins = bins[1:]\n\nfor bin in bins:\n a = [0 for k in range(m)]\n price = 0\n for i in range(n):\n if bin[i] == '1':\n for j in range(m):\n a[j] += l[i][j+1]\n \n price += l[i][0]\n \n \n \n if min(a) >= x:\n min_price = min(price, min_price)\n \n\nif min_price == 10**9:\n print(-1)\n exit()\n \nprint(min_price)"]
['Runtime Error', 'Accepted']
['s390228480', 's119314437']
[9316.0, 9656.0]
[25.0, 90.0]
[625, 662]
p02683
u805332733
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\nfrom itertools import combinations\nimport numpy as np\n\ndef resolve():\n N, M, X = map(int, input().split(" "))\n\n books = []\n for i in range(N):\n CA = [int(x) for x in input().split(" ")]\n books.append(CA)\n\n books = np.array(books).reshape([N, M + 1])\n\n books_index_pattarns = [list(x) for i in range(1, N) for x in combinations(range(0, N), i)]\n books_result = np.array([np.sum(books[x], axis=0) for x in books_index_pattarns])\n books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)]\n # books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)][:,:1]\n\n if len(books_result) == 0:\n print(-1)\n return True\n elif len(books_result) == 1:\n print(books_result[0])\n return True\n else:\n print(books_result[:,:1].min())\n return True\n\nif __name__ == "__main__":\n resolve()', 'def resolve():\n N, M, X = map(int, input().split(" "))\n\n books = []\n for i in range(N):\n CA = [int(x) for x in input().split(" ")]\n books.append(CA)\n\n books = np.array(books)\n\n books_index_pattarns = [list(x) for i in range(1, N) for x in combinations(range(0, N), i)]\n books_result = np.array([np.sum(books[x], axis=0) for x in books_index_pattarns])\n # books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)]\n books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)][:,:1]\n if len(books_result) == 0:\n print("-1")\n return True\n else:\n print(books_result.min())\n return True\n\nif __name__ == "__main__":\n resolve()', 'from itertools import product\nfrom itertools import combinations\nimport numpy as np\n\ndef resolve():\n N, M, X = map(int, input().split(" "))\n\n books = []\n for i in range(N):\n CA = [int(x) for x in input().split(" ")]\n books.append(CA)\n\n books = np.array(books)\n\n\n if N == 1:\n if np.all(books[:, 1:] >= X):\n print(books[0][0])\n else:\n print(-1)\n return True\n books_index_pattarns = [list(x) for i in range(1, N+1) for x in combinations(range(0, N), i)]\n books_result = np.array([np.sum(books[x], axis=0) for x in books_index_pattarns])\n books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)]\n\n if len(books_result) == 0:\n print(-1)\n return True\n elif len(books_result) == 1:\n print(books_result[0][0])\n return True\n else:\n # print(books_result)\n print(books_result[:,:1].min())\n return True\n\nif __name__ == "__main__":\n resolve()']
['Runtime Error', 'Runtime Error', 'Accepted']
['s039631228', 's666493377', 's317440702']
[29020.0, 9240.0, 29108.0]
[134.0, 21.0, 141.0]
[854, 670, 901]
p02683
u808817704
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)', '#from collections import defaultdict, deque\nimport itertools\nimport numpy as np\n\ndef main():\n N, M, X = tuple(int(c) for c in input().split(\' \'))\n C = []\n A = []\n for _ in range(N):\n tmp = tuple(int(c) for c in input().split(\' \'))\n C.append(tmp[0])\n A.append(np.array(tmp[1:]))\n\n \n \n \n \n \n # print(-1)\n # exit()\n\n \n cmin = -1\n for n in range(1, N+1):\n for t in itertools.combinations(range(N), n):\n ri = np.zeros(M)\n ctmp = 0\n for i in t:\n ri += A[i]\n ctmp += C[i]\n if min(ri) >= X: \n if cmin == -1:\n cmin = ctmp\n elif ctmp < cmin:\n cmin = ctmp\n print(cmin)\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s001494370', 's638546660']
[9092.0, 27168.0]
[21.0, 146.0]
[9, 1000]
p02683
u809495242
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 x in range(N)] \n\nskill = [0]*M\nflag = [0]*M \nsaisyou = 10**7\nfor p in range(2**N):\n for q in range(N):\n if p >> q & 1: \n money += C[q][0]\n for r in range(M): \n skill[r] += C[q][r+1]\n print(skill)\n for s in range(M):\n if skill[s] >= X:\n flag[s] = 1\n if 0 not in flag and money < saisyou:\n saisyou = money\n money = 0\n skill = [0]*M\n flag = [0]*M\nif saisyou == 10**7:\n saisyou = -1\nprint(saisyou)\n\n\n\n', 'N, M, X = map(int,input().split())\nC = [list(map(int,input().split())) for x in range(N)] \n\nskill = [0]*M\nflag = [0]*M \nsaisyou = 10**7\nfor p in range(2**N):\n for q in range(N):\n if p >> q & 1: \n money += C[q][0]\n for r in range(M): \n skill[r] += C[q][r+1]\n for s in range(M):\n if skill[s] >= X:\n flag[s] = 1\n if 0 not in flag and money < saisyou:\n saisyou = money\n money = 0\n skill = [0]*M\n flag = [0]*M\nif saisyou == 10**7:\n saisyou = -1\nprint(saisyou)\n\n\n\n']
['Wrong Answer', 'Accepted']
['s202511800', 's086278802']
[9268.0, 9216.0]
[108.0, 103.0]
[716, 699]
p02683
u814271993
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,import numpy as np\nimport itertools\nn, m, x = map(int, input().split())\na = np.dot([i for i in itertools.product([0, 1], repeat = n)],\n [list(map(int, input().split())) for _ in range(n)])\nb = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)\nprint(min(a[:, 0][b]) if b.sum() else '-1')", "a,b,import numpy as np\nimport itertools\nn, m, x = map(int, input().split())\na = np.dot([i for i in itertools.product([0, 1], repeat = n)],\n [list(map(int, input().split())) for _ in range(n)])\nb = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)\nprint(min(a[:, 0][b]) if b.sum() else '-1')\n", "import numpy as np\nimport itertools\nn, m, x = map(int, input().split())\na = np.dot([i for i in itertools.product([0, 1], repeat = n)],\n [list(map(int, input().split())) for _ in range(n)])\nb = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)\nprint(min(a[:, 0][b]) if b.sum() else '-1')\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s024284082', 's504141407', 's197718057']
[8880.0, 8972.0, 27964.0]
[24.0, 25.0, 126.0]
[304, 305, 301]
p02683
u821989875
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())\nca = [list(int(i) for i in input().split()) for i in range(n)]\n\ncost_list = []\nfor choice in range(n+1):\n for v in itertools.combinations(ca, choice):\n cost = 0\n us = [0] * m\n for t in v:\n cost += t[0]\n for i in range(m):\n us[i] += t[i+1]\n flag = True\n for check in range(m):\n if us[check] < x:\n flag = False\n if flag == True:\n cost_list.append(cost)\n print(cost, us, cost_list)\n\nif len(cost_list) == 0:\n print(-1)\nelse:\n print(min(cost_list))\n', 'import itertools\nn, m, x = map(int, input().split())\nca = [list(int(i) for i in input().split()) for i in range(n)]\n\ncost_list = []\nfor choice in range(n+1):\n for v in itertools.combinations(ca, choice):\n cost = 0\n us = [0] * m\n for t in v:\n cost += t[0]\n for i in range(m):\n us[i] += t[i+1]\n flag = True\n for check in range(m):\n if us[check] < x:\n flag = False\n if flag == True:\n cost_list.append(cost)\n\nif len(cost_list) == 0:\n print(-1)\nelse:\n print(min(cost_list))\n']
['Wrong Answer', 'Accepted']
['s774424445', 's065508621']
[67032.0, 9256.0]
[1531.0, 78.0]
[555, 524]
p02683
u823885866
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, k = map(int, input().split())\nli = []\nfor t in range(n):\n li.append(list(map(int, input().split())))\nprice_list = []\nfor bit in range(1, 2**n):\n index_list = []\n for i in range(n):\n if bit & 1<<i:\n index_list.append(i)\n\n s = 0\n c = 0\n for t in range(1,m+1):\n for i in index_list:\n s += li[i][t]\n if s >= k:\n c += 1\n else:\n continue\n\n if c == m:\n p = 0\n for i in index_list:\n p += li[i][0]\n price_list.append(p)\n\nif len(price_list):\n print(price_list)\nelse:\n print('-1')\n \n", "n, m, k = map(int, input().split())\nli = []\nfor t in range(n):\n li.append(list(map(int, input().split())))\nprice_list = []\nfor bit in range(1, 2**n):\n index_list = []\n for i in range(n):\n if bit & 1<<i:\n index_list.append(i)\n\n s = 0\n c = 0\n for t in range(1,m+1):\n for i in index_list:\n s += li[i][t]\n if s >= k:\n c += 1\n else:\n break\n else:\n if c == m:\n p = 0\n for i in index_list:\n p += li[i][0]\n price_list.append(p)\n\nif len(price_list):\n print(price_list)\nelse:\n print('-1')", "n, m, k = map(int, input().split())\nli = []\nfor t in range(n):\n li.append(list(map(int, input().split())))\nprice_list = []\nfor bit in range(1, 2**n):\n index_list = []\n for i in range(n):\n if bit & 1<<i:\n index_list.append(i)\n\n c = 0\n for t in range(1,m+1):\n s = 0\n for i in index_list:\n s += li[i][t]\n if s >= k:\n c += 1\n else:\n break\n\n if c == m:\n p = 0\n for i in index_list:\n p += li[i][0]\n price_list.append(p)\n\nif len(price_list):\n print(min(price_list))\nelse:\n print('-1')\n \n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s423009928', 's728999790', 's945894746']
[9296.0, 9292.0, 9228.0]
[80.0, 74.0, 75.0]
[616, 632, 622]
p02683
u825541307
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 = []\nfor i in range(N):\n C.append(list(map(int,input().split())))\n\ncost = 100000000000000000000000\nl = list(range(1,N+1))\nimport itertools\nfor i in range(1,N+1):\n check_l = list(itertools.combinations(l,i))\n for a in check_l:\n sub_list = [0] * (M + 1)\n for j in range(i):\n for k in range(M+1):\n sub_list[k] += C[a[i-1]-1][k]\n flag = True\n for p in range(M):\n if sub_list[p+1] < X:\n flag = False\n if flag == True:\n if cost > sub_list[0]:\n cost = sub_list[0]\n\nif cost == 100000000000000000000000:\n print(-1)\nelse:\n print(cost)', 'N,M,X = map(int,input().split())\nC = []\nfor i in range(N):\n C.append(list(map(int,input().split())))\n\ncost = 100000000000000000000000\nl = list(range(1,N+1))\nimport itertools\nfor i in range(1,N+1):\n check_l = list(itertools.combinations(l,i))\n for a in check_l:\n sub_list = [0] * (M + 1)\n for j in range(i):\n for k in range(M+1):\n sub_list[k] += C[a[i]-1][k]\n flag = True\n for p in range(M):\n if sub_list[p+1] < X:\n flag = False\n if flag == True:\n if cost > sub_list[0]:\n cost = sub_list[0]\n\nif cost == 100000000000000000000000:\n print(-1)\nelse:\n print(cost)', 'N,M,X = map(int,input().split())\nC = []\nfor i in range(N):\n C.append(list(map(int,input().split())))\n\ncost = 100000000000000000000000\nl = list(range(1,N+1))\nfor i in range(2**N):\n check = [0]*N\n sub_list = [0]*(M+1)\n for j in range(N):\n if (i >> j) & 1 == 1:\n check[j] = 1\n for k in range(N):\n if check[k] == 1:\n for p in range(M+1):\n sub_list[p] += C[k][p]\n flag = True\n for q in range(M):\n if sub_list[q+1] < X:\n flag = False\n if flag == True:\n cost = min(sub_list[0],cost)\n\nif cost == 100000000000000000000000:\n print(-1)\nelse:\n print(cost)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s671396338', 's919924719', 's219825947']
[9376.0, 9252.0, 9180.0]
[95.0, 25.0, 95.0]
[687, 685, 649]
p02683
u829249049
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())\nALL=[]\ncost=0\nfor i in range(N):\n listA=list(map(int,input().split()))\n ALL+=[listA]\n cost+=listA[0]\nfor i in range(1,M+1):\n SUM=0\n for k in range(N):\n SUM+=ALL[k][i]\n if SUM<X:\n print(-1)\n sys.exit()\nALL.sort(reverse=True)\ncost2=0\nfor start in range(1,N):\n for i in range(M+1):\n SUM=0\n for k in range(start,N):\n SUM+=ALL[k][i]\n if SUM<X:\n print(cost-cost2)\n sys.exit()\n cost2+=ALL[start-1][0] ', 'import sys,itertools\nN,M,X=map(int,input().split())\nALL=[]\ncost=0\nfor i in range(N):\n listA=list(map(int,input().split()))\n ALL+=[listA]\n cost+=listA[0]\nfor i in range(1,M+1):\n SUM=0\n for k in range(N):\n SUM+=ALL[k][i]\n if SUM<X:\n print(-1)\n sys.exit()\ncost2=10**9 \nfor take in range(1,N+1):\n takeL=list(itertools.combinations(list(range(N)),take))\n for t in takeL:\n for i in range(1,M+1):\n SUM=0\n cost3=0\n for k in range(take):\n SUM+=ALL[t[k]][i]\n cost3+=ALL[t[k]][0]\n if SUM<X:\n break\n if i==M:\n cost2=min(cost2,cost3)\nprint(cost2) ']
['Wrong Answer', 'Accepted']
['s961632650', 's531671822']
[9236.0, 9292.0]
[22.0, 117.0]
[478, 615]
p02683
u830054172
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\nC = np.array([list(map(int, input().split())) for _ in range(N)])\n# print(C)\nsum_C = np.sum(C,axis=0)\n# print(sum_C)\n\nfor num in sum_C:\n if num < X:\n print(-1)\n exit()\n\ncost = float("inf")\n\nfor ii in [0, 1]:\n for i in range(M+1):\n cc = sorted(C, key=lambda x:x[0], reverse=True)\n ccc = np.array(sorted(cc, key=lambda x:x[i], reverse=ii))\n # print("ccc", ccc)\n sum_Ccopy = np.zeros(M+1)\n for j in range(N):\n sum_Ccopy += ccc[j]\n\n # print(np.all(sum_Ccopy[1:] >= X))\n # print(sum_Ccopy[0])\n if np.all(sum_Ccopy[1:] >= X):\n cost = min(cost, sum_Ccopy[0])\n # print(sum_Ccopy[0])\n print("sum_Ccopy", sum_Ccopy)\n # print(cost)\n \nprint(int(cost))\n\n\n', 'import numpy as np\n\nN, M, X = map(int, input().split())\n\nC = np.array([list(map(int, input().split())) for _ in range(N)])\n# print(C)\nsum_C = np.sum(C,axis=0)\n# print(sum_C)\n\nfor num in sum_C:\n if num < X:\n print(-1)\n exit()\n\ncost = float("inf")\n\nfor ii in [0, 1]:\n for i in range(M+1):\n cc = sorted(C, key=lambda x:x[0], reverse=False)\n ccc = np.array(sorted(cc, key=lambda x:x[i], reverse=ii))\n # print("ccc", ccc)\n sum_Ccopy = np.zeros(M+1)\n for j in range(N):\n sum_Ccopy += ccc[j]\n\n # print(np.all(sum_Ccopy[1:] >= X))\n # print(sum_Ccopy[0])\n if np.all(sum_Ccopy[1:] >= X):\n cost = min(cost, sum_Ccopy[0])\n # print(sum_Ccopy[0])\n print("sum_Ccopy", sum_Ccopy)\n # print(cost)\n \nprint(int(cost))\n\n\n', 'import numpy as np\n\nN, M, X = map(int, input().split())\n\nC = np.array([list(map(int, input().split())) for _ in range(N)])\n# print(C)\nsum_C = np.sum(C,axis=0)\n# print(sum_C)\n\nfor num in sum_C:\n if num < X:\n print(-1)\n exit()\n\ncost = float("inf")\nfor ij in [0, 1]:\n for ii in [0, 1]:\n for i in range(M+1):\n cc = sorted(C, key=lambda x:x[0], reverse=ij)\n ccc = np.array(sorted(cc, key=lambda x:x[i], reverse=ii))\n # print("ccc", ccc)\n sum_Ccopy = np.zeros(M+1)\n for j in range(N):\n sum_Ccopy += ccc[j]\n\n # print(np.all(sum_Ccopy[1:] >= X))\n # print(sum_Ccopy[0])\n if np.all(sum_Ccopy[1:] >= X):\n cost = min(cost, sum_Ccopy[0])\n # print(sum_Ccopy[0])\n print("sum_Ccopy", sum_Ccopy)\n # print(cost)\n \nprint(int(cost))\n\n\n', 'import numpy as np\n\nN, M, X = map(int, input().split())\n\nC = np.array([list(map(int, input().split())) for _ in range(N)])\n\ncost = float("inf")\n\nfor i in range(2**N):\n buy = np.zeros(M+1)\n for j in range(N):\n if ((i >> j)&1):\n buy += C[j]\n if np.all(buy[1:] >= X):\n cost = min(cost, buy[0])\n\nif cost == float("inf"):\n print(-1)\nelse:\n print(int(cost))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s187235549', 's738643423', 's972423936', 's279850071']
[27392.0, 27392.0, 27372.0, 27016.0]
[154.0, 135.0, 181.0, 364.0]
[857, 858, 932, 399]
p02683
u833071789
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 glob\nimport os\nimport numpy as np\n\n\nbn = os.path.basename(__file__).split(\'.\')[0]\ndn = os.path.dirname(__file__).split(\'/\')\n\n\nREL_PATH = dn[len(dn)-2] + \'\\\\\' + dn[len(dn)-1] + \'\\\\\' + bn\n\n\nTOP_PATH = \'C:\\\\AtCoder\'\n\nclass Common:\n\n problem = []\n index = 0\n\n def __init__(self, rel_path):\n self.rel_path = rel_path\n\n def initialize(self, path):\n file = open(path)\n self.problem = file.readlines()\n self.index = 0\n return\n\n def input_data(self):\n try:\n IS_TEST\n self.index += 1\n return self.problem[self.index-1]\n\n except NameError:\n return input()\n\n def resolve(self):\n pass\n\n def exec_resolve(self):\n try:\n IS_TEST\n for path in glob.glob(TOP_PATH + \'\\\\\' + self.rel_path + \'/*.txt\'):\n print("Test: " + path)\n self.initialize(path)\n self.resolve()\n print("\\n\\n")\n except NameError:\n self.resolve()\n\n\nclass Solver(Common):\n\n def rec(self, N, M, X, now_index, now_knowledge, now_price, books):\n\n if now_index > N:\n return 12 * 10**5 +1\n\n next_knowledge = now_knowledge + books[now_index][1:]\n if np.min(next_knowledge) >= X:\n result1 = now_price + books[now_index][0]\n else:\n result1 = self.rec(N, M, X, now_index+1, next_knowledge, now_price + books[now_index][0], books)\n\n result2 = self.rec(N, M, X, now_index+1, now_knowledge, now_price, books)\n\n if result1 < result2:\n return result1\n else:\n return result2\n\n def resolve(self):\n\n N, M, X = map(int, self.input_data().split())\n\n books = [None]*(N+1)\n for i in range(N):\n books[i+1] = np.array(list(map(int, self.input_data().split())))\n\n print(books)\n print( np.zeros(M))\n\n result = self.rec(N, M, X, 1, np.zeros(M), 0, books)\n if result == 12 * 10**5 +1:\n print(\'-1\')\n else:\n print(str(result))\n\n\nsolver = Solver(REL_PATH)\nsolver.exec_resolve()\n', 'import glob\nimport os\nimport numpy as np\n\n\nbn = os.path.basename(__file__).split(\'.\')[0]\ndn = os.path.dirname(__file__).split(\'/\')\n\n\nREL_PATH = dn[len(dn)-2] + \'\\\\\' + dn[len(dn)-1] + \'\\\\\' + bn\n\n\nTOP_PATH = \'C:\\\\AtCoder\'\n\nclass Common:\n\n problem = []\n index = 0\n\n def __init__(self, rel_path):\n self.rel_path = rel_path\n\n def initialize(self, path):\n file = open(path)\n self.problem = file.readlines()\n self.index = 0\n return\n\n def input_data(self):\n try:\n IS_TEST\n self.index += 1\n return self.problem[self.index-1]\n\n except NameError:\n return input()\n\n def resolve(self):\n pass\n\n def exec_resolve(self):\n try:\n IS_TEST\n for path in glob.glob(TOP_PATH + \'\\\\\' + self.rel_path + \'/*.txt\'):\n print("Test: " + path)\n self.initialize(path)\n self.resolve()\n print("\\n\\n")\n except NameError:\n self.resolve()\n\n\nclass Solver(Common):\n\n def rec(self, N, M, X, now_index, now_knowledge, now_price, books):\n\n if now_index > N:\n return 12 * 10**5 +1\n\n next_knowledge = now_knowledge + books[now_index][1:]\n if np.min(next_knowledge) >= X:\n result1 = now_price + books[now_index][0]\n else:\n result1 = self.rec(N, M, X, now_index+1, next_knowledge, now_price + books[now_index][0], books)\n\n result2 = self.rec(N, M, X, now_index+1, now_knowledge, now_price, books)\n\n if result1 < result2:\n return result1\n else:\n return result2\n\n def resolve(self):\n\n N, M, X = map(int, self.input_data().split())\n\n books = [None]*(N+1)\n for i in range(N):\n books[i+1] = np.array(list(map(int, self.input_data().split())))\n\n result = self.rec(N, M, X, 1, np.zeros(M), 0, books)\n if result == 12 * 10**5 +1:\n print(\'-1\')\n else:\n print(str(result))\n\n\nsolver = Solver(REL_PATH)\nsolver.exec_resolve()\n']
['Wrong Answer', 'Accepted']
['s197177247', 's455711840']
[27272.0, 27208.0]
[138.0, 124.0]
[2245, 2195]
p02683
u837677955
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 copy\n\nN,M,X = map(int,input().split())\n\nres = 10**8\n\nC = [0] * N\nA = [0] * N\n\nfor i in range(N):\n L = list(map(int,input().split()))\n C[i] = L[0]\n A[i] = L[1:]\n\ndef sum_l(a,b):\n for i in range(len(a)):\n a[i] += b[i]\n return a\n\ndef check_x(a):\n for i in range(len(a)):\n if a[i] < X:\n return False\n return True\n\n\ndef calc_money_under(n):\n understand = [0] * M\n money = 0\n for s in range(N):\n if (n >> s) == 1:\n money += C[s]\n \n understand = copy.copy([x + y for (x,y) in zip(understand, A[s])])\n print(understand)\n \n if check_x(understand):\n res = min(sum(money), res)\n return\n\nfor n in range(2**N):\n calc_money_under(n)\n\nif res == 10**8:\n print(-1)\nelse:\n print(res)\n\n', 'import copy\n \nN,M,X = map(int,input().split())\n \nres = 10**8\n \nC = [0] * N\nA = [0] * N\n \nfor i in range(N):\n L = list(map(int,input().split()))\n C[i] = L[0]\n A[i] = L[1:]\n \ndef check_x(a):\n for i in range(len(a)):\n if a[i] < X:\n return False\n return True\n \n\ndef calc_money_under(n):\n global res\n\n understand = [0] * M\n money = 0\n for s in range(N):\n if (n >> s) & 1:\n money += C[s]\n for j in range(M):\n understand[j] += A[s][j]\n \n \n if check_x(understand):\n res = min(money, res)\n return\n \nfor n in range(2**N):\n calc_money_under(n)\n \nif res == 10**8:\n print(-1)\nelse:\n print(res)']
['Runtime Error', 'Accepted']
['s739479545', 's734906399']
[9340.0, 9332.0]
[49.0, 71.0]
[859, 749]
p02683
u838560769
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\n###\n# main\nif(__name__ == \'__main__\'):\n # input\n n, m, x = map(int, input().split(" "))\n\n book = []\n c_sum = 0\n sum_li = [0 for _ in range(m)]\n cp_dict = [{} for _ in range(m)]\n for i in range(n):\n b = list(map(int, input().split(" ")))\n book.append(b)\n c = b[0]\n c_sum += c\n for al in range(m):\n a = b[al+1]\n cp = a/c\n cp_dict[al][cp] = c\n sum_li[al] += a\n\n ans = -1\n for al in range(m):\n if sum_li[al] < x:\n break\n else:\n ans = c_sum\n\n print(ans)\n\n# else:\n # do nothing', '# -*- coding: utf-8 -*-\n\n###\n# main\nif(__name__ == \'__main__\'):\n # input\n n, m, x = map(int, input().split(" "))\n\n book = []\n c_sum = 0\n sum_li = [0 for _ in range(m)]\n for i in range(n):\n b = list(map(int, input().split(" ")))\n book.append(b)\n c = b[0]\n c_sum += c\n for al in range(m):\n a = b[al+1]\n sum_li[al] += a\n\n ans = -1\n for al in range(m):\n if sum_li[al] < x:\n break\n else:\n q = []\n cost_list = [c_sum]\n init_list = [c_sum]\n for al in range(m):\n init_list.append(sum_li[al])\n q.append(init_list)\n\n for i in range(n):\n for tgt_cnt in range(len(q)):\n tgt = q[tgt_cnt]\n cost = tgt[0] - book[i][0]\n tgt_list = [cost]\n for al in range(m):\n cp = tgt[al+1] - book[i][al+1]\n if cp < x:\n break\n else:\n tgt_list.append(cp)\n else:\n cost_list.append(cost)\n q.append(tgt_list)\n\n cost_list.sort()\n ans = cost_list[0]\n\n print(ans)\n\n# else:\n # do nothing']
['Wrong Answer', 'Accepted']
['s760786647', 's919959650']
[9236.0, 11352.0]
[23.0, 38.0]
[636, 1249]
p02683
u838959206
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 = [[0 for i in range(m)] for _ in range(n)]\nc = [0] * n\nfor sankousyo in range(n):\n c_and_a = list(map(int,input().split()))\n c[sankousyo] = c_and_a[0]\n a[sankousyo] = c_and_a[1:]\n \ncost = [0] * (2**n)\nINF = 10**12\nres_cost = INF\nfor i in range(2**n):\n understandings = [0] * m\n cost_sum = 0\n for j in range(n):\n if (i >> j) & 1:\n\n cost_sum += c[j]\n \n for k in range(m):\n understandings[k] = understandings[k] + a[j][k]\n\n res = True\n for j in range(n):\n if understandings[j] < x:\n res = False \n\n if res:\n if res_cost > cost_sum:\n res_cost = cost_sum\n\nif res_cost == INF:\n print(-1)\nelse:\n print(f"お会計は{res_cost}円です")\n', 'n, m, x = map(int,input().split())\n\na = [[0 for i in range(m)] for _ in range(n)]\nc = [0] * n\nfor sankousyo in range(n):\n c_and_a = list(map(int,input().split()))\n c[sankousyo] = c_and_a[0]\n a[sankousyo] = c_and_a[1:]\n \ncost = [0] * (2**n)\nINF = 10**12\nres_cost = INF\nfor i in range(2**n):\n understandings = [0] * m\n cost_sum = 0\n for j in range(n):\n if (i >> j) & 1:\n\n cost_sum += c[j]\n \n for k in range(m):\n understandings[k] = understandings[k] + a[j][k]\n\n res = True\n for j in range(m):\n if understandings[j] < x:\n res = False \n\n if res:\n if res_cost > cost_sum:\n res_cost = cost_sum\n\nif res_cost == INF:\n print(-1)\nelse:\n print(f"お会計は{res_cost}円です")', 'n, m, x = map(int,input().split())\n\na = [[0 for i in range(m)] for _ in range(n)]\nc = [0] * n\nfor sankousyo in range(n):\n c_and_a = list(map(int,input().split()))\n c[sankousyo] = c_and_a[0]\n a[sankousyo] = c_and_a[1:]\n \ncost = [0] * (2**n)\nINF = 10**12\nres_cost = INF\nfor i in range(2**n):\n understandings = [0] * m\n cost_sum = 0\n for j in range(n):\n if (i >> j) & 1:\n\n cost_sum += c[j]\n \n for k in range(m):\n understandings[k] = understandings[k] + a[j][k]\n\n res = True\n for j in range(m):\n if understandings[j] < x:\n res = False \n\n if res:\n if res_cost > cost_sum:\n res_cost = cost_sum\n\nif res_cost == INF:\n print(-1)\nelse:\n print(res_cost)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s021362451', 's250273394', 's361718810']
[9212.0, 9280.0, 9152.0]
[88.0, 86.0, 87.0]
[796, 795, 770]
p02683
u845573105
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())\nC = []\nA = [[] for i in range(M)]\nresC = []\nresA = list(A)\n\nNEW = 0\n\ndef update(base):\n #print(NEW,base)\n if base==None:\n return NEW\n return base + NEW\n\ndef check(num):\n return num>=X\n\ndef check2(*args):\n res = True\n for val in args:\n buf = (val >= X)\n res = res and buf\n return res\n\nfor i in range(N):\n buf = list(map(int, input().split()))\n C.append(buf[0])\n for j in range(M):\n A[j].append(buf[j+1])\n\nfor i in range(N):\n if i == 0:\n NEW = C[i]\n resC = [0, NEW]\n resA = [[0, A[j][i]] for j in range(M)]\n else:\n NEW = C[i]\n resC = resC + list(map(update, resC))\n for j in range(M):\n NEW = A[j][i]\n resA[j] = resA[j] + list(map(update, resA[j]))\n\nres = list(map(check2, *resA))\nprint(np.asarray(resC)[res]) \nif sum(res)==0:\n print(-1)\nelse:\n print(min(np.asarray(resC)[res]))', 'import numpy as np\n\nN, M, X = map(int, input().split())\nC = []\nA = [[] for i in range(M)]\nresC = []\nresA = list(A)\n\nNEW = 0\n\ndef update(base):\n #print(NEW,base)\n if base==None:\n return NEW\n return base + NEW\n\ndef check(num):\n return num>=X\n\ndef check2(*args):\n res = True\n for val in args:\n buf = (val >= X)\n res = res and buf\n return res\n\nfor i in range(N):\n buf = list(map(int, input().split()))\n C.append(buf[0])\n for j in range(M):\n A[j].append(buf[j+1])\n\nfor i in range(N):\n if i == 0:\n NEW = C[i]\n resC = [0, NEW]\n resA = [[0, A[j][i]] for j in range(M)]\n else:\n NEW = C[i]\n resC = resC + list(map(update, resC))\n for j in range(M):\n NEW = A[j][i]\n resA[j] = resA[j] + list(map(update, resA[j]))\n\nres = list(map(check2, *resA))\n#print(np.asarray(resC)[res]) \nif sum(res)==0:\n print(-1)\nelse:\n print(min(np.asarray(resC)[res]))']
['Wrong Answer', 'Accepted']
['s960678559', 's586626766']
[28908.0, 29032.0]
[117.0, 114.0]
[885, 886]
p02683
u852790844
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\n\nread = sys.stdin.read\n\nn, m, k = map(int, input().split())\nca = np.array(read().split(), dtype=np.int64).reshape([n,m+1])\n\nans = 10**8\n\nfor i in range(2**n):\n b = np.array(list(format(i,\'0\'+str(n)+\'b\')), dtype=np.int64)\n print(b)\n d = ca[b == 1].sum(axis=0)\n print(d)\n if np.all(d[1:] >= k):\n ans = min(ans, d[0])\n\nif ans == 10**8:\n print("-1")\nelse:\n print(ans)', 'import sys\nimport numpy as np\n\nread = sys.stdin.read\n\nn, m, k = map(int, input().split())\nca = np.array(read().split(), dtype=np.int64).reshape([n,m+1])\n\nans = 10**8\n\nfor i in range(2**n):\n b = np.array(list(format(i,\'0\'+str(n)+\'b\')), dtype=np.int64)\n d = ca[b == 1].sum(axis=0)\n if np.all(d[1:] >= k):\n ans = min(ans, d[0])\n\nif ans == 10**8:\n print("-1")\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s972209700', 's860315378']
[27468.0, 27320.0]
[528.0, 162.0]
[421, 395]
p02683
u854962015
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=[list(map(int,input().split())) for i in range(N)]\nS=[]\nfor i in range(2**N):\n A=[]\n b=0\n for j in range(M):\n a=0\n for k in range(N):\n if (i>>j & 1):\n a+=L[k][j+1]\n b+=L[k][0]\n A.append(a)\n T=True\n for l in A:\n if l<X:\n T=False\n if T==True:\n S.append(b//M)\n #print(A)\nS=sorted(S)\nif len(S)==0:\n print(-1)\nelse:\n print(S[0])\n\n ', 'N,M,X=map(int,input().split())\nL=[list(map(int,input().split())) for i in range(N)]\na=2**N\nJ=[]\nfor i in range(a):\n T=True\n K=[0]*(M+1)\n for j in range(N):\n if (i>>j)&1:\n for k in range(M+1):\n K[k]+=L[j][k]\n for j in range(1,M+1):\n if K[j]<X:\n T=False\n if T:\n J.append(K[0])\nif len(J)==0:\n print(-1)\nelse:\n J.sort()\n print(J[0])']
['Wrong Answer', 'Accepted']
['s551893031', 's901465245']
[9224.0, 9112.0]
[167.0, 95.0]
[412, 410]
p02683
u863370423
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 check(understanding,X):\n for individual in understanding:\n if individual<X:\n return False\n return True\n\ncost=0\ninputs1 =list(map(int, input().split()[:3]))\nN=inputs1[0]\nM=inputs1[1]\nX=inputs1[2]\n\nmatrix=[]\nunderstanding= []\nfor i in range(N):\n inputs =list(map(int, input().split()[:M+1]))\n matrix.append(inputs)\n\nfor i in range(N):\n cost+=matrix[i][0]\n for j in range(1,M+1):\n understanding[j]+=matrix[i][j]\n if check(understanding,X):\n print(cost)\n break\n\nif not check(understanding,X):\n print(-1)', 'n, m, x = map(int, input().split())\n\na = []\nc = []\n\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 = 100000000\n\nans = INF\n\nfor i in range(1 << n):\n cost = 0\n d = [0] * m\n for j in range(n):\n if i >> j & 1:\n cost += c[j]\n for k in range(m):\n d[k] += a[j][k]\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\n']
['Runtime Error', 'Accepted']
['s263762725', 's483246580']
[9140.0, 9160.0]
[23.0, 81.0]
[566, 543]
p02683
u863433366
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\nn, m, x = map(int, input().split())\nca = list(map(int, input().split()))\n\nans = 10**9\nfor i in range(1,n+1):\n for j in combinations(ca, i):\n s = [0]*(m+1)\n for k in j:\n for l in range(m+1):\n s[l] += k[l]\n if min(s[1:]) <= x:\n ans += min(ans, s[0])\nif ans == 10**9:\n print(-1)\nelse:\n print(ans)\n ', 'from itertools import combinations\nn, m, x = map(int, input().split())\nca = [list(map(int, input().split())) for _ in range(n)]\n\nans = 10**9\nfor i in range(1,n+1):\n for j in combinations(ca, i):\n s = [0]*(m+1)\n for k in j:\n for l in range(m+1):\n s[l] += k[l]\n if min(s[1:]) >= x:\n ans = min(ans, s[0])\nif ans == 10**9:\n print(-1)\nelse:\n print(ans)']
['Runtime Error', 'Accepted']
['s567082855', 's905603717']
[9176.0, 9144.0]
[23.0, 71.0]
[362, 376]
p02683
u867826040
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(map(int,input().split())) for i in range(n)]\nb = [sum([i/j[0] for i in j[1:]]) for k,j in enumerate(a)]\nc = sorted(b,reverse=True)\nl = [0]*m\np = 0\nfor i in c:\n if all([i>=x for i in l]):\n break\n f = a[b.index(i)]\n print(f,i)\n p+=f[0]\n for k,j in enumerate(f[1:]):\n l[k]+=j\nif all([i>=x for i in l]):\n print(p)\nelse:\n print(-1)', 'n, m, x = map(int, input().split())\nans = 10000000\nbs = []\nfor i in range(n):\n bs.append(tuple(map(int, input().split())))\n\nfor i in range(2**n):\n a = [0]*m\n c = 0\n for j in range(n):\n if (i>>j)&1:\n c += bs[j][0]\n for k in range(m):\n a[k]+=bs[j][k+1]\n if all([ai >= x for ai in a]):\n ans = min(ans,c)\nif ans == 10000000:\n print(-1)\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s827983954', 's531507130']
[9068.0, 9160.0]
[23.0, 94.0]
[404, 421]
p02683
u871841829
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] * N\nA = []\n\nfor __ in range(N):\n nums = list(map(int, input().split()))\n C[__] = nums[0]\n A.append(nums[1:])\nmincost = 10e9\nok = False\nfor i in range(1 << N):\n cost = 0\n skill = [0] * M\n\n for u in range(N):\n if i & (1<<u):\n cost += C[u]\n for si, s in enumerate(A[u]):\n skill[si] += s\n \n \n if all([s >= X for s in skill]):\n ok = True\n if mincost > cost:\n mincost = cost\n\nprint(mincost if ok else -1)\n dp\n', 'N, M, X = map(int, input().split())\nC = [0] * N\nA = []\n\nfor __ in range(N):\n nums = list(map(int, input().split()))\n C[__] = nums[0]\n A.append(nums[1:])\n\nmincost = 10e9\nok = False\nfor i in range(1 << N):\n cost = 0\n skill = [0] * M\n\n for u in range(N):\n if i & (1<<u):\n cost += C[u]\n for si, s in enumerate(A[u]):\n skill[si] += s\n \n \n if all([s >= X for s in skill]):\n ok = True\n if mincost > cost:\n mincost = cost\n\nprint(mincost if ok else -1)\n']
['Runtime Error', 'Accepted']
['s358963330', 's679635326']
[9004.0, 9164.0]
[26.0, 83.0]
[550, 547]
p02683
u875541136
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())\nitems = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)\n\nout = 10**18\nfor c in itertools.product([False, True], repeat=M):\n tmp = np.sum(items[[np.where(c)]], axis=0)\n if np.any(tmp):\n if M == np.count_nonzero(tmp[1:] >= X):\n out = min(out, tmp[0])\nif out == 10**18:\n print(-1)\nelse:\n print(out) ', 'import itertools\nimport numpy as np\n\nN, M, X = map(int, input().split())\nitems = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)\n\nout = 10**18\nfor c in itertools.product([False, True], repeat=M):\n tmp = np.sum(items[[np.where(c)]], axis=0)\n if np.any(tmp):\n if M == np.count_nonzero(tmp[1:] >= X):\n out = min(out, tmp[0])\nif out == 10**18:\n print(-1)\nelse:\n print(out) ', 'import itertools\nimport numpy as np\n\nN, M, X = map(int, input().split())\nitems = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)\n\nout = 10**18\nfor c in itertools.product([False, True], repeat=N):\n tmp = np.sum(items[np.where(c)], axis=0)\n if M == np.count_nonzero(tmp[1:] >= X):\n out = min(out, tmp[0])\n\nif out == 10**18:\n print(-1)\nelse:\n print(out) ']
['Runtime Error', 'Runtime Error', 'Accepted']
['s273108389', 's760411725', 's560006004']
[27408.0, 27500.0, 27348.0]
[172.0, 178.0, 155.0]
[419, 419, 394]
p02683
u876438858
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 math import sqrt\nfrom collections import Counter, defaultdict, deque\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 6)\n\n\ndef I():\n return int(input())\n\n\ndef MI():\n return map(int, input().split())\n\n\ndef LI():\n return list(MI())\n\n\ndef LIN(n: int):\n return [I() for _ in range(n)]\n\n\ninf = float("inf")\nmod = 10 ** 9 + 7\n\n\ndef main():\n n, m, x = MI()\n li = [LI() for _ in range(n)]\n\n min = float(inf)\n for i in range(2 ** n):\n flag = True\n total = [0] * (m + 1)\n for j in range(n):\n if (i >> j) & 1:\n total = [x + y for (x, y) in zip(total, li[j])]\n\n print(total)\n for t in total[1:]:\n if t < x:\n flag = False\n\n if flag:\n if total[0] < min:\n min = total[0]\n\n if isinstance(min, float):\n print(-1)\n else:\n print(min)\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\nfrom math import sqrt\nfrom collections import Counter, defaultdict, deque\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 6)\n\n\ndef I():\n return int(input())\n\n\ndef MI():\n return map(int, input().split())\n\n\ndef LI():\n return list(MI())\n\n\ndef LIN(n: int):\n return [I() for _ in range(n)]\n\n\ninf = float("inf")\nmod = 10 ** 9 + 7\n\n\ndef main():\n n, m, x = MI()\n li = [LI() for _ in range(n)]\n\n min = float(inf)\n for i in range(2 ** n):\n flag = True\n total = [0] * (m + 1)\n for j in range(n):\n if (i >> j) & 1:\n total = [x + y for (x, y) in zip(total, li[j])]\n\n for t in total[1:]:\n if t < x:\n flag = False\n\n if flag:\n if total[0] < min:\n min = total[0]\n\n if isinstance(min, float):\n print(-1)\n else:\n print(min)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s491554648', 's594480615']
[9508.0, 9428.0]
[63.0, 57.0]
[942, 921]
p02683
u880400515
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()))\nC = []\nA = []\n\nfor i in range(N):\n input_line = list(map(int, input().split()))\n C.append(input_line[0])\n A.append(input_line[1:])\n\nmin_cost = 10 ** 7\nflag_i = False\nfor i in range(1, N+1):\n comb_list = list(itertools.combinations(range(N), i))\n \n\n for comb in comb_list:\n know = [0] * M\n cost = 0\n for book in comb:\n\n for i in range(M):\n know[i] += A[book][i]\n cost += C[book]\n \n \n flag = True\n for i in range(M):\n if (know[i] < X):\n flag = False\n \n \n if (flag):\n flag_i = True\n \n if (min_cost > cost):\n min_cost = cost\nif (flag_i):\n print(min_cost)\n \n\nprint(-1)\n\n \n', 'import itertools\n\nN, M, X = list(map(int, input().split()))\nC = []\nA = []\n\nfor i in range(N):\n input_line = list(map(int, input().split()))\n C.append(input_line[0])\n A.append(input_line[1:])\n\nflag_i = False\nmin_cost = 10**7\n\nfor i in range(1, N+1):\n comb_list = list(itertools.combinations(range(N), i))\n \n for comb in comb_list:\n know = [0] * M\n cost = 0\n for book in comb:\n\n for i in range(M):\n know[i] += A[book][i]\n cost += C[book]\n \n \n flag = True\n for i in range(M):\n if (know[i] < X):\n flag = False\n \n \n if (flag):\n flag_i = True\n \n if (min_cost > cost):\n min_cost = cost\nif (flag_i):\n print(min_cost)\n exit(0)\n\nprint(-1)\n\n \n']
['Wrong Answer', 'Accepted']
['s418459992', 's740898599']
[9388.0, 9340.0]
[72.0, 72.0]
[868, 869]
p02683
u883307604
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.
["ef can_reach_the_goal(u, x):\n return min(u) >= x\n\nn, m, x = map(int, input().split())\n\nc = []\na = []\nfor i in range(n):\n ca = [int(row) for row in input().split()]\n c.append(ca[0])\n a.append(ca[1:])\n\nINF = 10**7\nmin_cost = INF\nfor k in range(2**n):\n purchase = [True if c == '1' else False for c in list(format(k, '0{}b'.format(n)))]\n cost = 0\n u = [0]*m\n for i in range(n):\n cost += c[i] if purchase[i] else 0\n for j in range(m):\n u[j] += a[i][j] if purchase[i] else 0\n\n if can_reach_the_goal(u, x) and cost < min_cost:\n min_cost = cost\n\nif min_cost == INF:\n print(-1)\nelse:\n print(min_cost)", 'import sys\nimport numpy as np\n\ndef can_reach_the_goal(u, x):\n return min(u) >= x\n\nn, m, x = map(int, input().split())\n\nc = []\na = []\nu = [0]*m\nu_sum = [0]*n\nfor i in range(n):\n ca = [int(row) for row in input().split()]\n c.append(ca[0])\n a.append(ca[1:])\n u_sum[i] += sum(a[i])\n for j in range(m):\n u[j] += a[i][j]\n\nif not can_reach_the_goal(u, x):\n print(-1)\n sys.exit(-1)\n\nidx_c = list(np.argsort(-1 * np.array(c)))\nc_sum = sum(c)\nfor i in idx_c:\n print(c[i])\n u_tmp = [u[j] - a[i][j] for j in range(m)]\n if can_reach_the_goal(u_tmp, x):\n c_sum -= c[i]\n u = u_tmp\n\nprint(c_sum)', "def can_reach_the_goal(u, x):\n return min(u) >= x\n\nn, m, x = map(int, input().split())\n\nc = []\na = []\nfor i in range(n):\n ca = [int(row) for row in input().split()]\n c.append(ca[0])\n a.append(ca[1:])\n\nINF = 10**7\nmin_cost = INF\nfor k in range(2**n):\n purchase = [True if c == '1' else False for c in list(format(k, '0{}b'.format(n)))]\n cost = 0\n u = [0]*m\n for i in range(n):\n cost += c[i] if purchase[i] else 0\n for j in range(m):\n u[j] += a[i][j] if purchase[i] else 0\n\n if can_reach_the_goal(u, x) and cost < min_cost:\n min_cost = cost\n\nif min_cost == INF:\n print(-1)\nelse:\n print(min_cost)\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s457532085', 's850259391', 's868622838']
[8952.0, 27184.0, 9128.0]
[22.0, 108.0, 136.0]
[657, 633, 659]
p02683
u886362575
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\n\nCmin = 10**10\nN, M, X = map(int, input().split())\nL = np.array([[int(j) for j in input().split()] for i in range(N)])\nfor i in range(N):\n for idx in itertools.combinations(list(range(N)), i+1):\n A = np.zeros(M+1, dtype=int)\n for j in idx:\n A = A + L[j]\n print(A)\n if A[0] < Cmin and (A[1:] >= X).all() == True:\n Cmin = A[0]\nif Cmin == 10**10:\n print(-1)\n exit()\nprint(Cmin)', 'import numpy as np\nimport itertools\n\nCmin = 10**10\nN, M, X = map(int, input().split())\nL = np.array([[int(j) for j in input().split()] for i in range(N)])\nfor i in range(N):\n for idx in itertools.combinations(list(range(N)), i+1):\n A = np.zeros(M+1, dtype=int)\n A = A + np.sum(L[list(idx)], axis=0)\n if A[0] < Cmin and (A[1:] >= X).all() == True:\n Cmin = A[0]\nif Cmin == 10**10:\n print(-1)\n exit()\nprint(Cmin)']
['Wrong Answer', 'Accepted']
['s862659468', 's433284186']
[27392.0, 27396.0]
[336.0, 161.0]
[435, 426]
p02683
u894172792
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\ndata = input().split()\nn = int(data[0])\nm = int(data[1])\nx = int(data[2])\ndata = []\nfor _ in range(n):\n data.append(np.array(list(map(int,input().split()))))\n\nans = 10000000\nfor b in range(2**n):\n value = np.array([0 for _ in range(m+1)])\n b = bin(b)[2:]\n for zero in range(n-len(b)):\n b = "0" + b\n for i in range(n):\n if b[i] == 1:\n value += data[i]\n ok = True\n for i in range(1,m+1):\n if value[i] < x:\n ok = False\n if ok == True and value[0] <= ans:\n ans = value[0]\n\nprint(ans)\n ', 'import numpy as np\n\ndata = input().split()\nn = int(data[0])\nm = int(data[1])\nx = int(data[2])\ndata = []\nfor _ in range(n):\n data.append(np.array(list(map(int,input().split()))))\n\nINF = 10000000\nans = INF\nfor b in range(2**n):\n value = np.array([0 for _ in range(m+1)])\n b = bin(b)[2:]\n for zero in range(n-len(b)):\n b = "0" + b\n for i in range(n):\n if b[i] == "1":\n value += data[i]\n ok = True\n for i in range(1,m+1):\n if value[i] < x:\n ok = False\n if ok == True and value[0] <= ans:\n ans = value[0]\nif ans == INF:\n print(-1)\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s029561337', 's983398099']
[27180.0, 27072.0]
[136.0, 160.0]
[586, 623]
p02683
u909802005
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 python3\nimport itertools\n\ndef main():\n N, M, X = map(int, input().split())\n C = [0] * N\n A = []\n for n in range(0, N):\n l = input().split()\n C[n] = int(l[0])\n A.append([int(i) for i in l[1:]])\n print(C[n], A[n])\n\n min_cost = sum(C) + 1\n for i in range(N):\n for comb in itertools.combinations(range(N), i):\n canAchive = True\n for m in range(M):\n r = 0\n for n in comb:\n r += A[n][m]\n if (r < X):\n canAchive = False\n break\n if (canAchive):\n cost = sum([C[n] for n in comb])\n min_cost = min(min_cost, cost)\n\n if (min_cost <= sum(C)):\n print(min_cost)\n else:\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python3\nimport itertools\n\ndef main():\n N, M, X = map(int, input().split())\n C = [0] * N\n A = []\n for n in range(0, N):\n l = input().split()\n C[n] = int(l[0])\n A.append([int(i) for i in l[1:]])\n\n min_cost = sum(C) + 1\n globalCanAchive = False\n for i in range(1,N+1):\n for comb in itertools.combinations(range(N), i):\n canAchive = True\n for m in range(M):\n r = sum([A[n][m] for n in comb])\n if (r < X):\n canAchive = False\n break\n if (canAchive):\n globalCanAchive = True\n cost = sum([C[n] for n in comb])\n min_cost = min(min_cost, cost)\n\n if (globalCanAchive):\n print(min_cost)\n else:\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s964077858', 's847638238']
[9252.0, 9112.0]
[40.0, 52.0]
[858, 863]
p02683
u917734688
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())\ndatas = []\npoint = [0]*M\nm = 0\nmax = 0\ncount = 0\nfor i in range(N):\n datas.append(list(map(int,input().split())))\nprint(datas)\nwhile 1:\n for data in datas:\n if sum(data[1:-1]) > max:\n ans = count\n max = sum(data[1:-1])\n count += 1\n for i in range(M):\n point[i] += datas[ans][i+1]\n m += datas[ans][0]\n if all([x >= 10 for x in point]):\n print(m)\n break\n datas.pop(ans)\n if len(datas) == 0:\n print(-1)\n break\n max,ans,count = 0,0,0\n', 'import itertools\nN,M,X = map(int,input().split())\nA = [list(map(int,input().split())) for _ in range(N)]\nB = list(itertools.product([0,1], repeat=N))\nsums = {}\nanss = []\nfor i in range(N):\n for b in B:\n ans = 0\n Point = [0]*M\n count = 0\n for z in b:\n if z == 1:\n for k in range(M):\n Point[k] += A[count][k+1]\n ans += A[count][0]\n if M == len([Point[n] for n in range(M) if Point[n] >= X]):\n anss.append(ans)\n count += 1\nif len(anss) != 0:\n print(min(anss))\nelse:\n print(-1)\n']
['Runtime Error', 'Accepted']
['s423274824', 's889776415']
[27108.0, 20016.0]
[104.0, 1108.0]
[577, 616]
p02683
u919235786
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=map(int,input().split())\na=[]\nfor i in range(n):\n ai=list(map(int,input().split()))\n a.append(ai)\n\n\nmaxi=[0 for i in range(m)]\nfor i in range(n):\n for j in range(m):\n maxi[j]+=a[i][j+1]\nfor i in range(m):\n if maxi[i]<x:\n print(-1)\n exit()\n\nmini=100000000\n\nfor i in range(2**n):\n d=[]\n for j in range(n):\n if((i>>j)& 1):\n d.append(j)\n print(d)\n b=[0 for j in range(m)]\n \n c=0\n \n for j in d:\n c+=a[j][0]\n for k in range(m):\n b[k]+=a[j][k+1]\n l=0\n for j in b:\n if j<x:\n l=1\n if l==0:\n mini=min(mini,c)\n\nprint(mini)', 'n,m,x=map(int,input().split())\na=[]\nfor i in range(n):\n ai=list(map(int,input().split()))\n a.append(ai)\nmini=10000000\n\n\nfor i in range(2**n):\n d=[]\n for j in range(n):\n if((i>>j)and 1):\n d.append(j)\n b=[0 for k in range(m)]\n \n c=0\n \n for j in d:\n c+=a[j][0]\n for k in range(m):\n b[k]+=a[j][k+1]\n l=0\n for j in b:\n if j<x:\n l=1\n if l==0:\n mini=min(mini,c)\n\nif mini==10000000:\n print(-1)\nelse: print(mini)\n\n', 'n,m,x=map(int,input().split())\na=[]\nfor i in range(n):\n ai=list(map(int,input().split()))\n a.append(ai)\nmini=1000000000\n\n\nfor i in range(2**n):\n d=[]\n for j in range(n):\n if((i>>j)and 1):\n d.append(j)\n b=[0 for k in range(m)]\n \n c=0\n \n for j in d:\n c+=a[j][0]\n for k in range(m):\n b[k]+=a[j][k+1]\n l=0\n for j in b:\n if j<x:\n l=1\n if l==0:\n mini=min(mini,c)\n\nif mini==1000000000:\n print(-1)\nelse: print(mini)\n\n', '\nn,m,x=map(int,input().split())\na=[]\nfor i in range(n):\n ai=list(map(int,input().split()))\n a.append(ai)\n\nmaxi=[0 for i in range(m)]\nfor i in range(n):\n for j in range(m):\n maxi[j]+=a[i][j+1]\nfor i in range(m):\n if maxi[i]<x:\n print(-1)\n exit()\n\nmini=100000000\n\nfor i in range(2**n):\n d=[]\n for j in range(n):\n if((i>>j)and 1):\n d.append(j)\n b=[0 for j in range(m)]\n \n c=0\n \n for j in d:\n c+=a[j][0]\n for k in range(m):\n b[k]+=a[j][k+1]\n l=0\n for j in b:\n if j<x:\n l=1\n if l==0:\n mini=min(mini,c)\n\nprint(mini)', '\nn,m,x=map(int,input().split())\na=[]\nfor i in range(n):\n ai=list(map(int,input().split()))\n a.append(ai)\n\n\nmaxi=[0 for i in range(m)]\nfor i in range(n):\n for j in range(m):\n maxi[j]+=a[i][j+1]\nfor i in range(m):\n if maxi[i]<x:\n print(-1)\n exit()\n\nmini=100000000\n\nfor i in range(2**n):\n d=[]\n for j in range(n):\n if((i>>j)& 1):\n d.append(j)\n b=[0 for j in range(m)]\n \n c=0\n \n for j in d:\n c+=a[j][0]\n for k in range(m):\n b[k]+=a[j][k+1]\n l=0\n for j in b:\n if j<x:\n l=1\n if l==0:\n mini=min(mini,c)\n\nprint(mini)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s078852150', 's118077201', 's544933523', 's740396325', 's208573248']
[9088.0, 9264.0, 9152.0, 9248.0, 9160.0]
[95.0, 136.0, 140.0, 136.0, 90.0]
[708, 536, 540, 683, 696]
p02683
u923662841
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())\nlista = [list(map(int,input().split())) for i in range(N)]\n\nlista = np.array(lista)\njudge = [X]*M\ncost = 1200001\ndata = [a for a in range(1,N+1)] # [1,2,3,...,N]\n\nfor i in range(1,N+1):\n j = list(itertools.combinations(data, i))\n for k in j:\n result = np.array([0]*(M+1))\n for l in k:\n result = result + lista[l-1]\n if all(result[1:]>=judge):\n if reslut[0]<cost:\n cost = result[0]\n m = k\nc = 0\n\ntry:\n for i in m:\n c +=lista[i-1][0]\n \n print(c)\n \nexcept:\n print(-1)', 'import itertools\nimport numpy as np\n\nN,M,X = map(int, input().split())\nlista = [list(map(int,input().split())) for i in range(N)]\n\nlista = np.array(lista)\njudge = [X]*M\ncost = 1200001\ndata = [a for a in range(1,N+1)] # [1,2,3,...,N]\n\nfor i in range(1,N+1):\n j = list(itertools.combinations(data, i))\n for k in j:\n result = np.array([0]*(M+1))\n for l in k:\n result = result + lista[l-1]\n if all(result[1:]>=judge):\n if result[0]<cost:\n cost = result[0]\n m = k\nc = 0\n\ntry:\n for i in m:\n c +=lista[i-1][0]\n \n print(c)\nexcept:\n print(-1)', 'import itertools\nimport numpy as np\n\nN,M,X = map(int, input().split())\nlista = [list(map(int,input().split())) for i in range(N)]\n\nlista = np.array(lista)\njudge = [X]*M\ncost = 1200001\ndata = [a for a in range(1,N+1)] # [1,2,3,...,N]\n\nfor i in range(1,N+1):\n j = list(itertools.combinations(data, i))\n for k in j:\n result = np.array([0]*(M+1))\n for l in k:\n result = result + lista[l-1]\n if all(result[1:]>=judge):\n if reslut[0]<cost:\n cost = result[0]\n m = k\nc = 0\n\ntry:\n for i in m:\n c +=lista[i-1][0]\n \n print(c)\nexcept:', 'import itertools\nimport numpy as np\n\nN,M,X = map(int, input().split())\nlista = [list(map(int,input().split())) for i in range(N)]\n\nlista = np.array(lista)\njudge = [X]*M\ncost = 120000000000\ndata = [a for a in range(1,N+1)] # [1,2,3,...,N]\n\nfor i in range(1,N+1):\n j = list(itertools.combinations(data, i))\n for k in j:\n result = np.array([0]*(M+1))\n for l in k:\n result = result + lista[l-1]\n if all(result[1:]>=judge):\n if result[0]<cost:\n cost = result[0]\n m = k\nc = 0\n\ntry:\n for i in m:\n c +=lista[i-1][0]\n \n print(c)\nexcept:\n print(-1)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s348027231', 's372962084', 's447623465', 's467119771']
[27480.0, 27524.0, 9080.0, 27560.0]
[196.0, 209.0, 24.0, 141.0]
[588, 589, 617, 636]
p02683
u927282564
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()))\ns = [list(map(int, input().split())) for i in range(N)]\nlist_N = [i for i in range(N)]\n\nans = []\nfor num_book in range(1, N + 1):\n for i in itertools.combinations(list_N, num_book):\n #print(i)\n temp = 0\n for j in range(1, M + 1):\n sum_line = sum([s[i[k]][j] for k in range(num_book)])\n if sum_line < X:\n break\n temp += 1\n if temp == M:\n score=sum([s[i[k]][0] for k in range(num_book)])\n #print(score)\n ans.append(score)\n #if len(ans) != 0:\n # break\nif len(ans)==0:\n print(-1)\nelse:\n print(ans)\n print(min(ans))', 'import itertools\n\nN, M, X = list(map(int, input().split()))\ns = [list(map(int, input().split())) for i in range(N)]\nlist_N = [i for i in range(N)]\n\nans = []\nfor num_book in range(1, N + 1):\n for i in itertools.combinations(list_N, num_book):\n #print(i)\n temp = 0\n for j in range(1, M + 1):\n sum_line = sum([s[i[k]][j] for k in range(num_book)])\n if sum_line < X:\n break\n temp += 1\n if temp == M:\n score=sum([s[i[k]][0] for k in range(num_book)])\n #print(score)\n ans.append(score)\n #if len(ans) != 0:\n # break\nif len(ans)==0:\n print(-1)\nelse:\n #print(ans)\n print(min(ans))\n']
['Wrong Answer', 'Accepted']
['s099172597', 's410786419']
[9328.0, 9264.0]
[73.0, 75.0]
[716, 718]
p02683
u932868243
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,k=map(int,input().split())\nl=list(map(int,input().split()))\nlist=[l[0]]\nnum=0\nwhile True:\n if l[list[num]-1] in list:\n break\n list.append(l[list[num]-1])\n num+=1\ny=list.index(l[list[num]-1])\nx=len(list)-y\nans=list[y:]\nprint(ans[(k-y)%x-1])\nn,k=map(int,input().split())\nl=list(map(int,input().split()))\nlist=[l[0]]\nnum=0\nwhile True:\n if l[list[num]-1] in set(list):\n break\n list.append(l[list[num]-1])\n num+=1\ny=list.index(l[list[num]-1])\nx=len(list)-y\nans=list[y:]\nprint(ans[(k-y)%x-1])\n提出情報 \n', 'import itertools\nn,m,x=map(int,input().split())\nl=[list(map(int,input().split())) for i in range(n)]\nsum=[0]*m\nfor i in range(n):\n for j in range(1,m+2):\n sum[j]+=l[i][j]\nfor ss in sum:\n if ss<x:\n print(-1)\n exit()\nlist=[]\nfor p in itertools.product([1,0],n)\n cnt=[0]*m\n ans=0\n for i in range(n):\n if p[i]==1:\n ans+=l[i][0]\n list.append(ans)\n for j in range(1,m+1)\n cnt[j]+=l[i][j]\nprint(min(list))', 'import itertools\nn,m,x=map(in,input().split())\nl=[list(map(int,input().split())) for i in range(n)]\ncostl=[]\nfor p in itertools.product([0,1],n):\n al=[0]*m\n cost=0\n for i in range(n):\n if p[i]==1:\n cost+=l[i][0]\n for j in range(1,m):\n al[j-1]+=l[i][j]\n if all(mm>=x for mm in m):\n costl.append(cost)\nprint(min(cost))\n \n \n ', 'import itertools\nn,m,x=map(int,input().split())\nl=[list(map(int,input().split())) for i in range(n)]\ncostl=[]\nfor p in itertools.product([0,1],repeat=n):\n al=[0]*m\n cost=0\n for i in range(n):\n if p[i]==1:\n cost+=l[i][0]\n for j in range(1,m+1):\n al[j-1]+=l[i][j]\n if all(mm>=x for mm in al):\n costl.append(cost)\nprint(min(costl) if len(costl)>=1 else -1)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s300246283', 's577709396', 's796285563', 's727674428']
[9284.0, 9064.0, 9012.0, 9176.0]
[24.0, 22.0, 24.0, 87.0]
[515, 437, 366, 380]
p02683
u933129390
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())\nprace = []\nknow = []\nfor i in range(n):\n acc = list(map(int, input().split()))\n prace.append(acc[0])\n know.append(acc[1:])\n\nans = 10**10\nfor i in range(2**n):\n und = [0 for i in range(m)]\n f = "{:b}".format(i)\n s = f.zfill(n)\n mm = 0\n print(s)\n for j in range(len(s)):\n if s[j] == \'1\':\n for k in range(m):\n und[k] += know[j][k]\n mm += prace[j]\n for j in range(m):\n if und[j] < x:\n break\n else:\n ans = min(ans, mm)\nif ans == 10**10:\n print(-1)\nelse:\n print(ans)\n', 'n, m, x = map(int, input().split())\nprace = []\nknow = []\nfor i in range(n):\n acc = list(map(int, input().split()))\n prace.append(acc[0])\n know.append(acc[1:])\n\nans = 10**10\nfor i in range(2**n):\n und = [0 for i in range(m)]\n f = "{:b}".format(i)\n s = f.zfill(n)\n mm = 0\n for j in range(len(s)):\n if s[j] == \'1\':\n for k in range(m):\n und[k] += know[j][k]\n mm += prace[j]\n for j in range(m):\n if und[j] < x:\n break\n else:\n ans = min(ans, mm)\nif ans == 10**10:\n print(-1)\nelse:\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s427208526', 's071419204']
[9236.0, 9228.0]
[82.0, 82.0]
[605, 592]
p02683
u940765148
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(k) for k in input().split()]\nc = np.zeros(n, dtype=int)\na = np.zeros((n, m), dtype=int)\nrikai_a = np.zeros(m, dtype=int)\nbool_c = np.full(n, False)\nfor i in range(n):\n c[i], *a[i] = [int(k) for k in input().split()]\ncost = np.sum(c) + 1\nfor nn in range(1,n+1):\n for k in itertools.combinations(np.argsort(c),nn):\n k = list(k)\n cs = sum(c[k].flatten())\n if cs > cost:\n break\n print(cs)\n rikai_a = np.sum(a[k],axis=0)\n if np.all(rikai_a >= x):\n cost = min(cost,cs)\n break\nif cost < np.sum(c) + 1:\n print(cost)\nelse:\n print(-1)', 'import numpy as np\nimport itertools\nn, m, x = [int(k) for k in input().split()]\nc = np.zeros(n, dtype=int)\na = np.zeros((n, m), dtype=int)\nfor i in range(n):\n c[i], *a[i] = [int(k) for k in input().split()]\ncost = np.sum(c) + 1\nfor nn in range(1,n+1):\n for k in itertools.combinations(np.argsort(c),nn):\n k = list(k)\n cs = np.sum(c[k].flatten())\n if cs > cost:\n continue\n rikai = np.sum(a[k],axis=0)\n if np.all(rikai >= x):\n cost = min(cost,cs)\nif cost < np.sum(c) + 1:\n print(cost)\nelse:\n print(-1)']
['Wrong Answer', 'Accepted']
['s186567101', 's494280508']
[27296.0, 27328.0]
[184.0, 179.0]
[662, 568]
p02683
u941644149
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())\nList = [list(map(int, input().split())) for n in range(N)]\nINF = 10**7\nans = INF\nC_pro = list(itertools.product([0,1], repeat=N))\n\nfor c_pro in C_pro:\n count = 0\n cost = 0\n ans_list = [0 for i in range(M)]\n for c in c_pro:\n if c == 1:\n cost += List[count][0]\n ans_list = [ans+list for ans, list in zip(ans_list,List[count][1:])]\n count += 1\n if ans_list >= [X for i in range(M)]:\n ans = min(ans, cost)\n \n\nif ans == INF:\n print(-1)\nelse:\n print(ans)', 'import itertools\n\nN, M, X = map(int, input().split())\nList = [list(map(int, input().split())) for n in range(N)]\nINF = 10**7\nans = INF\nC_pro = list(itertools.product([0,1], repeat=N))\n\nfor c_pro in C_pro:\n count = 0\n cost = 0\n ans_list = [0 for i in range(M)]\n for c in c_pro:\n if c == 1:\n cost += List[count][0]\n ans_list = [answ+list for answ, list in zip(ans_list,List[count][1:])]\n count += 1\n ok = True\n for i in range(len(ans_list)):\n if ans_list[i] < X:\n ok = False\n break\n if ok:\n ans = min(ans, cost)\n \n\nif ans == 10**7:\n print(-1)\nelse:\n print(ans)']
['Runtime Error', 'Accepted']
['s479943071', 's867583994']
[9224.0, 9620.0]
[23.0, 60.0]
[551, 660]
p02683
u941645670
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.
['#c\nn,m,x=map(int, input().split())\nsp = [list(map(int, input().split())) for _ in range(m)]\n\nimport copy\nresult = []\ndef test(i,i_sum,cost):\n \n flag = 0\n if i <= n:\n for j in range(m):\n if i_sum[j] < x:\n flag = 1\n break\n\n if flag == 1:\n test(copy.deepcopy(i)+1, i_sum[:],cost)\n\n for j in range(1,m+1):\n i_sum[j-1] += sp[i-1][j]\n cost[0] += sp[i-1][0]\n test(copy.deepcopy(i)+1, i_sum[:],cost)\n else:\n result.append(cost[0])\ntest(0,[0]*n,[0])\n\nif result != []:\n print(min(result))\nelse:\n print(-1)', '#c\nn,m,x=map(int, input().split())\nsp = [list(map(int, input().split())) for _ in range(m)]\n\nimport copy\nresult = []\ndef test(i,i_sum,cost):\n \n flag = 0\n if i <= n:\n print(i,i_sum,cost)\n for j in range(m):\n if i_sum[j] < x:\n flag = 1\n break\n\n if flag == 1:\n test(copy.deepcopy(i)+1, i_sum[:],cost[:])\n\n for j in range(1,m+1):\n i_sum[j-1] += sp[i-1][j]\n cost[0] += sp[i-1][0]\n test(copy.deepcopy(i)+1, i_sum[:],cost[:])\n else:\n result.append(cost[0])\ntest(0,[0]*n,[0])\n\nif result != []:\n print(min(result))\nelse:\n print(-1)', '#c\nn,m,x=map(int, input().split())\nsp = [list(map(int, input().split())) for _ in range(m)]\n\nimport copy\nresult = []\ndef test(i,i_sum,cost):\n \n flag = 0\n if i <= n:\n print(i,i_sum,cost)\n for j in range(m):\n if i_sum[j] < x:\n flag = 1\n break\n\n if flag == 1:\n test(copy.deepcopy(i)+1, i_sum[:],cost)\n\n for j in range(1,m+1):\n i_sum[j-1] += sp[i-1][j]\n cost[0] += sp[i-1][0]\n test(copy.deepcopy(i)+1, i_sum[:],cost)\n else:\n result.append(cost[0])\ntest(0,[0]*n,[0])\n\nif result != []:\n print(min(result))\nelse:\n print(-1)', 'n,m,x = map(int, input().split())\nc= []\na= []\nans = float(\'inf\')\nfor i in range(n):\n c_tmp, *a_tmp = map(int, input().split())\n c.append(c_tmp)\n a.append(a_tmp)\n\n\ncost_l =[]\n\nfor i in range(2 ** len(c)):\n cost = 0\n skill = [0]*m\n for j in range(len(c)): \n if ((i >> j) & 1):\n cost += c[j]\n for k in range(m):\n skill[k] += int(a[j][k])\n \n f = 0\n for j in range(m):\n if skill[j] < x:\n f = 1\n break\n if f == 0:\n cost_l.append(cost)\n \nif cost_l != []:\n print(min(cost_l))\nelse:\n print("-1")']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s160143936', 's240709040', 's393370841', 's656087782']
[9360.0, 9284.0, 9360.0, 9164.0]
[46.0, 65.0, 64.0, 106.0]
[719, 752, 747, 614]
p02683
u942051624
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())\nList=[list(map(int,input().split())) for i in range(M)]\n\n\nprint(List)\nflag=True\ni=1\nchamp=100000\ntotal_cost=100000\nwhile flag:\n newlist=list(itertools.combinations(range(N),i))\n for j in range(len(newlist)):\n for s in range(1,M+1):\n if sum(List[t][s] for t in newlist[j])<X:\n flag2=False\n break\n if flag2!=False: \n total_cost=sum(List[t][0] for t in newlist[j])\n if total_cost<champ:\n champ=total_cost\n flag2=True\n if champ!=100000:\n print(champ)\n flag=False\n break\n i=i+1\n if i==N+1:\n break\n\nif flag: \n print(-1)', "N,M,X=map(int, input().split())\nList=[list(map(int,input().split())) for i in range(N)]\n\n\n\nans=10000000000000\nfor j in range(1,2**(N+1)-1):\n combinationlist=list(map(int, [i for i in format(2**(N+1)+j,'b')]))\n del combinationlist[0]\n sumoflist=[sum(combinationlist[s]*List[s][k] for s in range(N)) for k in range(M+1)]\n flag=True\n for t in range(1,M+1):\n if sumoflist[t]<X:\n flag=False\n break\n if flag and sumoflist[0]<ans:\n ans=sumoflist[0]\n\nif ans!=10000000000000:\n print(ans)\nelse:\n print(-1)"]
['Runtime Error', 'Accepted']
['s199198797', 's603207008']
[9388.0, 9224.0]
[30.0, 227.0]
[705, 555]
p02683
u949618949
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(" "))\nB_list = []\n\n\nfor Books in range(N):\n B_list.append(list(map(int, input().split(" "))))\n# print(B_list)\n\nbug = []\nfor k in range(M + 1):\n bug.append(0)\n#print(bug)\nways = []\n\nfor way in range(2**N):\n for book in range(N):\n if ((way >> book) & 1) == 1:\n for i in range(M + 1):\n bug[i] += B_list[book][i]\n\n # print(bug)\n clear = [l for l in bug if l >= X]\n #print(clear)\n bug.pop(0)\n O = clear.pop(0)\n\n if len(bug) == len(clear):\n ways.append(O)\n\n bug = []\n for k in range(M + 1):\n bug.append(0)\n\nif len(ways) == 0:\n print(-1)\nelse:\n print(min(ways))', 'N, M, X = map(int, input().split(" "))\nB_list = []\n\n\nfor Books in range(N):\n B_list.append(list(map(int, input().split(" "))))\n# print(B_list)\n\nbug = []\nfor k in range(M + 1):\n bug.append(0)\nprint(bug)\nways = []\n\nfor way in range(2**N):\n for book in range(N):\n if ((way >> book) & 1) == 1:\n for i in range(M + 1):\n bug[i] += B_list[book][i]\n\n # print(bug)\n clear = [l for l in bug if l >= X]\n print(clear)\n if len(bug) == len(clear):\n ways.append(bug[0])\n\n bug = []\n for k in range(M + 1):\n bug.append(0)\n\nif len(ways) == 0:\n print(-1)\nelse:\n print(min(ways))\n', 'N, M, X = map(int, input().split(" "))\nB_list = []\n\n\nfor Books in range(N):\n B_list.append(list(map(int, input().split(" "))))\n# print(B_list)\n\nbug = []\nfor k in range(M + 1):\n bug.append(0)\n# print(bug)\nways = []\n\nfor way in range(2**N):\n for book in range(N):\n if ((way >> book) & 1) == 1:\n for i in range(M + 1):\n bug[i] += B_list[book][i]\n\n # print(bug)\n O = bug.pop(0)\n clear = [l for l in bug if l >= X]\n # print(clear)\n\n if len(bug) == len(clear):\n ways.append(O)\n\n bug = []\n for k in range(M + 1):\n bug.append(0)\n\nif len(ways) == 0:\n print(-1)\nelse:\n print(min(ways))\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s078477202', 's727259884', 's370064635']
[9268.0, 9284.0, 9240.0]
[24.0, 96.0, 84.0]
[673, 640, 659]
p02683
u954153335
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())\nflg=np.zeros((m+1),dtype=int)\nminimn=-1\ndata=np.zeros((n,m+1))\nfor i in range(n):\n data[i]=list(map(int,input().split()))\nfor i in range(2**n):\n flg=np.zeros((m+1))\n for j in range(n):\n if (i>>j)&1:\n flg+=data[j]\n if all(flg[1:]>=x):\n if minimn==-1:\n minimn=flg[0]\n elif flg[0]<minimn:\n minimn=flg[0]\nprint(minimn)', 'import numpy as np\nn,m,x=map(int,input().split())\nflg=np.zeros((m+1),dtype=int)\nminimn=-1\ndata=np.zeros((n,m+1))\nfor i in range(n):\n data[i]=list(map(int,input().split()))\nfor i in range(2**n):\n flg=np.zeros((m+1))\n for j in range(n):\n if (i>>j)&1:\n flg+=data[j]\n if all(flg[1:]>=x):\n if minimn==-1:\n minimn=flg[0]\n elif flg[0]<minimn:\n minimn=flg[0]\nprint(int(minimn))']
['Wrong Answer', 'Accepted']
['s877136116', 's804609260']
[27068.0, 27096.0]
[147.0, 146.0]
[426, 431]
p02683
u958053648
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 \nimport itertools as it\nimport math\n \ncost = math.inf\nfor comb in it.chain(*(it.combinations(C, r) for r in range(1, n+1))):\n print(comb)\n print(*comb)\n c, *a = map(sum, zip(*comb))\n print(c,a)\n if c < cost and min(a) >= x:\n cost = c\n \nprint(-1 if cost is math.inf else cost)', 'n, m, x = map(int, input().split())\nC = [list(map(int, input().split())) for _ in range(n)]\n \nimport itertools as it\nimport math\n \ncost = math.inf\nfor comb in it.chain(*(it.combinations(C, r) for r in range(1, n+1))):\n c, *a = map(sum, zip(*comb))\n if c < cost and min(a) >= x:\n cost = c\n \nprint(-1 if cost is math.inf else cost)']
['Wrong Answer', 'Accepted']
['s928447240', 's241770874']
[9236.0, 9208.0]
[113.0, 29.0]
[390, 342]
p02683
u962423738
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 i in range(n)]\nans=0\nfor i in range(2**n):\n check=[0]*m\n ans_=0\n for j in range(n):\n if ((i>>j)&1):\n ans_+=ca[j][0]\n for k in range(m):\n check[k]+=ca[j][k+1]\n if all([l>=x for l in check]):\n ans=min(ans,ans_)\nif ans==0:\n print(-1)\nelse:\n print(ans)', 'n,m,x=map(int,input().split())\nca=[list(map(int,input().split())) for i in range(n)]\nans=0\nfor i in range(2**n):\n check=[0]*m\n ans_=0\n for j in range(n):\n if ((i>>j)&1):\n ans_+=ca[j][0]\n for k in range(m):\n check[k]+=ca[j][k+1]\n if all([l>=x for l in check]):\n ans=min(ans,ans_)\nif ans==0:\n print(-1)\nelse:\n print(ans)', 'n,m,x=map(int,input().split())\nca=[list(map(int,input().split())) for i in range(n)]\nans=100000000000000000\nfor i in range(2**n):\n check=[0]*m\n ans_=0\n for j in range(n):\n if ((i>>j)&1):\n ans_+=ca[j][0]\n for k in range(m):\n check[k]+=ca[j][k+1]\n if all([l>=x for l in check]):\n ans=min(ans,ans_)\nif ans==100000000000000000:\n print(-1)\nelse:\n print(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s037943166', 's874841853', 's782603614']
[9240.0, 9152.0, 9144.0]
[93.0, 95.0, 96.0]
[396, 396, 430]
p02683
u966207392
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)]\npattern = []\nfor i in range(2**N):\n lis = []\n for j in range(N):\n if ((i>>j)&1):\n lis.append(Ca[j])\n pattern.append(lis)\n\ncnt = []\nfor i in range(2**N):\n g = [0]*M\n for j in range(len(pattern[i])):\n for k in range(M+1):\n g[k] += pattern[i][j][k]\n if g[1]<X or g[2]<X or g[3]<X:\n continue\n else:\n cnt.append(g[0])\nprint(min(cnt))', 'N, M, X = map(int, input().split())\nCa = [list(map(int, input().split())) for _ in range(N)]\npattern = []\nfor i in range(2**N):\n lis = []\n for j in range(N):\n if ((i>>j)&1):\n lis.append(Ca[j])\n pattern.append(lis)\n\ncnt = []\nfor i in range(2**N):\n g = [0] * (M+1)\n for j in range(len(pattern[i])):\n for k in range(M+1):\n g[k] += pattern[i][j][k]\n x = g[1:M]\n if min(x) < X:\n continue\n else:\n cnt.append(g[0])\nif len(cnt) ==0:\n print(-1)\nelse:\n print(min(cnt))', 'N, M, X = map(int, input().split())\nCa = [list(map(int, input().split())) for _ in range(N)]\npattern = []\nfor i in range(2**N):\n lis = []\n for j in range(N):\n if ((i>>j)&1):\n lis.append(Ca[j])\n pattern.append(lis)\n\ncnt = []\nfor i in range(2**N):\n g = [0] * (M+1)\n for j in range(len(pattern[i])):\n for k in range(M+1):\n g[k] += pattern[i][j][k]\n if g[1:M] < X:\n continue\n else:\n cnt.append(g[0])\nif len(cnt) ==0:\n print(-1)\nelse:\n print(min(cnt))', 'N, M, X = map(int, input().split())\nCa = [list(map(int, input().split())) for _ in range(N)]\npattern = []\nfor i in range(2**N):\n lis = []\n for j in range(N):\n if ((i>>j)&1):\n lis.append(Ca[j])\n pattern.append(lis)\n\ncnt = []\nfor i in range(2**N):\n g = [0] * M+1\n for j in range(len(pattern[i])):\n for k in range(M+1):\n g[k] += pattern[i][j][k]\n if g[1]<X or g[2]<X or g[3]<X:\n continue\n else:\n cnt.append(g[0])\nprint(min(cnt))', 'N, M, X = map(int, input().split())\nCa = [list(map(int, input().split())) for _ in range(N)]\npattern = []\nfor i in range(2**N):\n lis = []\n for j in range(N):\n if ((i>>j)&1):\n lis.append(Ca[j])\n pattern.append(lis)\n\ncnt = []\nfor i in range(2**N):\n g = [0] * (M+1)\n for j in range(len(pattern[i])):\n for k in range(M+1):\n g[k] += pattern[i][j][k]\n if M==1 and g[1]< X:\n continue\n elif M>1 and min(g[1:M+1]) < X:\n continue\n else:\n cnt.append(g[0])\nif len(cnt) ==0:\n print(-1)\nelse:\n print(min(cnt))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s058124129', 's579700576', 's840754200', 's908569634', 's378344850']
[9312.0, 9436.0, 9512.0, 9300.0, 9704.0]
[37.0, 37.0, 37.0, 36.0, 108.0]
[492, 546, 523, 496, 582]