結果

問題 No.555 世界史のレポート
ユーザー tenten
提出日時 2020-09-07 23:41:58
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,328 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 74,732 KB
実行使用メモリ 41,888 KB
最終ジャッジ日時 2024-11-29 11:32:20
合計ジャッジ時間 12,156 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static int copy;
    static int paste;
    static long[] dp;
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	copy = sc.nextInt();
    	paste = sc.nextInt();
    	dp = new long[n + 1];
    	System.out.println(dfw(n));
	}
	
	static long dfw(int x) {
	    if (x == 1) {
	        return 0;
	    }
	    if (dp[x] == 0) {
	        dp[x] = Long.MAX_VALUE;
	        for (int i = 1; i * 2 <= x + 1; i++) {
	            dp[x] = Math.min(dp[x], dfw(i) + (x - 1) / i * paste + copy);
	        }
	    }
	    return dp[x];
	}
	
}
0