結果
| 問題 | No.914 Omiyage |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-13 01:31:54 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 428 bytes |
| 記録 | |
| コンパイル時間 | 178 ms |
| コンパイル使用メモリ | 84,992 KB |
| 実行使用メモリ | 94,976 KB |
| 最終ジャッジ日時 | 2026-04-08 11:45:39 |
| 合計ジャッジ時間 | 7,014 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 17 |
ソースコード
from heapq import *
N,M,K = map(int,input().split())
A = []
for _ in range(N):
a = list(map(int,input().split()))
a.sort()
A.append(a)
INF = 10**9
ans = 0
hq = [(-a,1) for a in A[0]]
while hq:
i,j = heappop(hq)
if j == N:
ans = max(ans,-i)
continue
for a in A[j]:
if -(i-a) > K:
break
heappush(hq,(i-a,j+1))
if ans == 0:
print(-1)
else:
print(K-ans)