Created
May 10, 2020 23:41
-
-
Save monhime/3fd3b2bcd46aeeaf081388c362971c94 to your computer and use it in GitHub Desktop.
ABC167 C問題 解答
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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