結果
| 問題 | 
                            No.37 遊園地のアトラクション
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-06-02 18:15:23 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,422 ms / 5,000 ms | 
| コード長 | 559 bytes | 
| コンパイル時間 | 100 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 63,616 KB | 
| 最終ジャッジ日時 | 2024-10-10 13:35:42 | 
| 合計ジャッジ時間 | 10,535 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 27 | 
ソースコード
import math
T=int(input())
N=int(input())
C=list(map(int,input().split()))
V=list(map(int,input().split()))
Z=list(zip(C,V))
Z2=Z[:]
O=0
for z in Z:
    c=z[0]
    v=z[1]
    while True:
        v=math.floor(v/2)
        if v<=0:
            break
        Z2.append((c,v))
A=[[0]*(T+1) for i in range(len(Z2)+1)]
for i in range(1,len(Z2)+1):
    for t in range(1,T+1):
        z=Z2[i-1]
        c=z[0]
        v=z[1]
        if t-c<0:
            A[i][t]=A[i-1][t]
        else:
            A[i][t]=max(A[i-1][t-c]+v,A[i-1][t])
    O=max(max(A[i]),O)
print(O)