Submission #13042367


Source Code Expand

Copy
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()

Submission Info

Submission Time
Task C - Skill Up
User charter
Language Python (3.8.2)
Score 300
Code Size 714 Byte
Status AC
Exec Time 53 ms
Memory 9520 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 24
Set Name Test Cases
sample sample01, sample02, sample03
All border01, border02, border03, border04, hand01, hand02, hand03, hand04, hand05, large01, large02, large03, large04, large05, large06, large07, large08, random01, random02, random03, random04, sample01, sample02, sample03
Case Name Status Exec Time Memory
border01 AC 34 ms 9344 KB
border02 AC 50 ms 9460 KB
border03 AC 33 ms 9048 KB
border04 AC 53 ms 9340 KB
hand01 AC 18 ms 8936 KB
hand02 AC 18 ms 9104 KB
hand03 AC 49 ms 9444 KB
hand04 AC 33 ms 9336 KB
hand05 AC 49 ms 9500 KB
large01 AC 51 ms 9336 KB
large02 AC 33 ms 9288 KB
large03 AC 53 ms 9516 KB
large04 AC 35 ms 9256 KB
large05 AC 33 ms 9160 KB
large06 AC 35 ms 9048 KB
large07 AC 49 ms 9452 KB
large08 AC 52 ms 9512 KB
random01 AC 18 ms 8940 KB
random02 AC 37 ms 9520 KB
random03 AC 33 ms 9052 KB
random04 AC 20 ms 8928 KB
sample01 AC 20 ms 9232 KB
sample02 AC 18 ms 9048 KB
sample03 AC 20 ms 8928 KB