結果

問題 No.555 世界史のレポート
ユーザー rpy3cpprpy3cpp
提出日時 2017-08-26 04:02:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-04-23 16:36:16
合計ジャッジ時間 2,418 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 31 ms
10,752 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 AC 33 ms
10,880 KB
testcase_07 AC 32 ms
10,752 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 32 ms
10,752 KB
testcase_10 AC 97 ms
11,904 KB
testcase_11 AC 101 ms
12,160 KB
testcase_12 AC 94 ms
11,904 KB
testcase_13 AC 86 ms
11,776 KB
testcase_14 AC 100 ms
12,032 KB
testcase_15 AC 102 ms
12,160 KB
testcase_16 AC 91 ms
11,904 KB
testcase_17 AC 99 ms
12,160 KB
testcase_18 AC 104 ms
12,288 KB
testcase_19 AC 124 ms
12,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N = int(input())
    C, V = map(int, input().split())
    return N, C, V

def solve(N, C, V):
    dp = [float('inf')] * (1 + N)
    dpN = float('inf')
    dp[0] = 0
    dp[1] = C
    for k in range(1, N):
        cost = dp[k] + C
        for m in range(2 * k, N, k):
            cost += V
            if dp[m] > cost: dp[m] = cost
        dpN = min(dpN, cost + V - C)
    return min(dpN, dp[N])

N, C, V = read_data()
print(solve(N, C, V))
0