結果

問題 No.914 Omiyage
ユーザー O2MT
提出日時 2020-12-13 01:09:31
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 485 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 92,528 KB
最終ジャッジ日時 2024-09-19 22:40:02
合計ジャッジ時間 6,639 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
N,M,K = map(int,input().split())
A = []
for _ in range(N):
    a = list(map(int,input().split()))
    a.sort()
    A.append(a)
ans = 0
def perm(n,s):
    global ans
    if n == N:
        ans = max(ans,s)
        return
    b = bisect_left(A[n],s)
    for i in range(b+1,-1,-1):
        if i >= M:
            continue
        if s+A[n][i] > K:
            continue
        perm(n+1,s+A[n][i])

perm(0,0)
if ans == 0:
    print(-1)
else:
    print(K-ans)
0