結果

問題 No.664 超能力者Aと株価予測
ユーザー maspymaspy
提出日時 2020-03-12 19:37:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,099 ms / 4,000 ms
コード長 572 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,336 KB
最終ジャッジ日時 2024-04-29 21:10:52
合計ジャッジ時間 13,956 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 520 ms
43,696 KB
testcase_01 AC 535 ms
43,700 KB
testcase_02 AC 528 ms
43,964 KB
testcase_03 AC 519 ms
44,336 KB
testcase_04 AC 524 ms
43,572 KB
testcase_05 AC 521 ms
43,704 KB
testcase_06 AC 531 ms
44,084 KB
testcase_07 AC 547 ms
43,700 KB
testcase_08 AC 658 ms
44,216 KB
testcase_09 AC 534 ms
43,952 KB
testcase_10 AC 1,059 ms
43,832 KB
testcase_11 AC 1,099 ms
44,336 KB
testcase_12 AC 1,058 ms
44,092 KB
testcase_13 AC 1,056 ms
43,836 KB
testcase_14 AC 530 ms
43,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np


# %%
N, M, K = map(int, readline().split())
A = np.array([0] + read().split(), np.int64)

# %%
dp = np.zeros((N + 2, M + 1), np.int64)
dp[0, 0] = K
dp[1, 0] = K
for sell in range(2, N + 2):
    dp[sell] = dp[sell - 1]
    for buy in range(1, sell):
        x = dp[buy - 1, :-1] + dp[buy - 1, :-1] // A[buy] * (A[sell] - A[buy])
        np.maximum(dp[sell, 1:], x, out=dp[sell, 1:])


# %%
print(dp.max())
0