結果
問題 |
No.949 飲酒プログラミングコンテスト
|
ユーザー |
![]() |
提出日時 | 2020-01-31 19:51:25 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 842 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 848,824 KB |
最終ジャッジ日時 | 2024-09-17 06:56:35 |
合計ジャッジ時間 | 6,800 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | MLE * 2 -- * 27 |
ソースコード
import bisect from collections import deque N = int(input()) A = [int(a) for a in input().split()] B = [int(b) for b in input().split()] D = [int(d) for d in input().split()] D.sort() dp = [[N]*(N+1) for _ in range(N+1)] for i in range(N+1): for j in range(N+1): if i+j > N: continue c = A[i] + B[j] dp[i][j] = bisect.bisect_right(D, c) - 1 ans = 0 q = deque() q.append((0, 0, N)) while q: temp = q.popleft() i = temp[0] j = temp[1] cnt = temp[2] ans = max(ans, i+j) if i+j == N: continue if 0 < dp[i+1][j] < cnt: q.append((i+1, j, dp[i+1][j])) elif dp[i+1][j] >= cnt > 0: q.append((i+1, j, cnt-1)) if 0 < dp[i][j+1] < cnt: q.append((i, j+1, dp[i][j+1])) elif dp[i][j+1] >= cnt > 0: q.append((i, j+1, cnt-1)) print(ans)