結果

問題 No.37 遊園地のアトラクション
ユーザー ゆるくゆるく
提出日時 2015-05-06 05:29:21
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 851 ms / 5,000 ms
コード長 718 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 10,756 KB
最終ジャッジ日時 2023-07-31 19:44:17
合計ジャッジ時間 8,557 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
10,756 KB
testcase_01 AC 36 ms
10,368 KB
testcase_02 AC 151 ms
10,384 KB
testcase_03 AC 217 ms
10,736 KB
testcase_04 AC 100 ms
10,432 KB
testcase_05 AC 151 ms
10,380 KB
testcase_06 AC 130 ms
10,608 KB
testcase_07 AC 641 ms
10,680 KB
testcase_08 AC 90 ms
10,640 KB
testcase_09 AC 49 ms
10,460 KB
testcase_10 AC 496 ms
10,724 KB
testcase_11 AC 485 ms
10,620 KB
testcase_12 AC 145 ms
10,464 KB
testcase_13 AC 194 ms
10,636 KB
testcase_14 AC 100 ms
10,460 KB
testcase_15 AC 117 ms
10,380 KB
testcase_16 AC 288 ms
10,640 KB
testcase_17 AC 239 ms
10,636 KB
testcase_18 AC 601 ms
10,728 KB
testcase_19 AC 47 ms
10,372 KB
testcase_20 AC 214 ms
10,468 KB
testcase_21 AC 104 ms
10,604 KB
testcase_22 AC 851 ms
10,612 KB
testcase_23 AC 32 ms
10,384 KB
testcase_24 AC 33 ms
10,460 KB
testcase_25 AC 32 ms
10,348 KB
testcase_26 AC 34 ms
10,396 KB
testcase_27 AC 126 ms
10,416 KB
testcase_28 AC 32 ms
10,464 KB
testcase_29 AC 86 ms
10,416 KB
testcase_30 AC 32 ms
10,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

t = int(input())
n = int(input())
ct = list(map(int, input().split()))
vt = list(map(int, input().split()))

dp = [0] * 20001
c = [0] * 2000
v = [0] * 2000
for i in range(n):
    c[i] = ct[i]
    v[i] = vt[i]
p = n
for i in range(n):
    j = c[i]
    k = v[i]
    while(1):
        k = k // 2
        if k == 0:
            break
        c[p] = j
        v[p] = k
        p += 1
for i in range(p):
    for j in reversed(range(t + 1 - c[i])):
        dp[j + c[i]] = max(dp[j + c[i]], dp[j] + v[i])
print(dp[t])
0