結果

問題 No.914 Omiyage
ユーザー komkompi
提出日時 2019-10-25 22:33:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 523 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 17,696 KB
最終ジャッジ日時 2024-09-13 04:47:46
合計ジャッジ時間 4,149 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 12 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
N,M,K=map(int,input().split())
l=[]

def saiki(i,money,ans):
    if i==N:
        if money==0:
            print(0)
            exit()
        else:
            return money
    temp=l[i]
    for item in temp[::-1]:
        if money-item>=0:
            ans=min(saiki(i+1,money-item,ans),ans)
        else:
            pass
    
    return ans        

for _ in range(N):
    l.append(list(map(int,input().split())))

a=(saiki(0,K,10**18))
if a==10**18:
    print(-1)
else:
    print(a)


0