結果

問題 No.555 世界史のレポート
ユーザー htensai
提出日時 2020-01-30 19:23:10
言語 Java
(openjdk 23)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 74,736 KB
実行使用メモリ 51,208 KB
最終ジャッジ日時 2024-09-16 03:48:07
合計ジャッジ時間 4,253 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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