結果
問題 |
No.3014 岩井満足性問題
|
ユーザー |
![]() |
提出日時 | 2025-01-25 18:52:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 565 ms / 3,000 ms |
コード長 | 917 bytes |
コンパイル時間 | 907 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 78,208 KB |
最終ジャッジ日時 | 2025-01-26 00:01:16 |
合計ジャッジ時間 | 4,891 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
from collections import defaultdict, Counter, deque from itertools import groupby, accumulate, combinations, permutations, product, combinations_with_replacement from bisect import bisect_left, bisect_right from operator import itemgetter import math from heapq import heapify, heappush, heappop LMI=lambda:list(map(int, input().split())) LMS=lambda:list(map(str, input().split())) MI=lambda:map(int, input().split()) MS=lambda:map(str, input().split()) II=lambda:int(input()) IS=lambda:input().split() LI=lambda:list(input()) INF=10**18 N,D,K=MI() A=LMI() C=LMI() dp=[[-INF]*(K+1) for i in range(D+1)] dp[0][0]=0 for n in range(N): for d in range(D-1, -1, -1): for k in range(K, -1, -1): if dp[d][k]!=-INF: next_cost=min(K, k+C[n]) dp[d+1][next_cost]=max(dp[d+1][next_cost], dp[d][k]+A[n]) ans=dp[-1][-1] if ans==-INF: print('No') else: print(ans)