結果

問題 No.555 世界史のレポート
ユーザー htensaihtensai
提出日時 2020-01-30 19:23:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 71,852 KB
実行使用メモリ 51,420 KB
最終ジャッジ日時 2023-10-14 08:40:38
合計ジャッジ時間 3,699 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
49,200 KB
testcase_01 AC 39 ms
49,332 KB
testcase_02 AC 37 ms
49,468 KB
testcase_03 AC 37 ms
49,376 KB
testcase_04 AC 36 ms
49,376 KB
testcase_05 AC 37 ms
49,208 KB
testcase_06 AC 37 ms
49,276 KB
testcase_07 AC 37 ms
49,268 KB
testcase_08 AC 39 ms
49,500 KB
testcase_09 AC 38 ms
49,724 KB
testcase_10 AC 57 ms
51,264 KB
testcase_11 AC 52 ms
51,420 KB
testcase_12 AC 51 ms
51,144 KB
testcase_13 AC 51 ms
49,844 KB
testcase_14 AC 53 ms
51,036 KB
testcase_15 AC 53 ms
51,144 KB
testcase_16 AC 49 ms
51,220 KB
testcase_17 AC 51 ms
51,376 KB
testcase_18 AC 52 ms
51,292 KB
testcase_19 AC 56 ms
51,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] first = br.readLine().split(" ", 2);
        int c = Integer.parseInt(first[0]);
        int v = Integer.parseInt(first[1]);
        int[] dp = new int[n * 2];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[1] = 0;
        for (int i = 1; i < n; i++) {
            int cur = i;
            int cost = dp[i] + c;
            while (cur < n) {
                cur += i;
                cost += v;
                dp[cur] = Math.min(dp[cur], cost);
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = n; i < dp.length; i++) {
            min = Math.min(min, dp[i]);
        }
        System.out.println(min);
    }
}
0