Skip to content

Instantly share code, notes, and snippets.

@monhime

monhime/ABC167C.gyp

Created May 10, 2020
Embed
What would you like to do?
ABC167 C問題 解答
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import product
def main():
n,m,x=map(int,input().split())
CA=[[int(_) for _ in input().split()] for i in range(n)]
ans=10**10
n_lis=list(product([True,False],repeat=n))
for comb in n_lis:
cunt=0
A=[0]*m
for i,ca in enumerate(CA):
if comb[i]:
cunt+=ca[0]
for j,aa in enumerate(ca[1:]):
A[j]+=aa
for a in A:
if a<x:
break
else:
ans=min(ans,cunt)
if ans==10**10:
print(-1)
else:
print(ans)
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.