Skip to content

Instantly share code, notes, and snippets.

@monhime
Created May 10, 2020 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monhime/3fd3b2bcd46aeeaf081388c362971c94 to your computer and use it in GitHub Desktop.
Save monhime/3fd3b2bcd46aeeaf081388c362971c94 to your computer and use it in GitHub Desktop.
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