結果

問題 No.555 世界史のレポート
ユーザー tentententen
提出日時 2020-09-07 23:41:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,351 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 2,838 ms
コンパイル使用メモリ 72,520 KB
実行使用メモリ 55,980 KB
最終ジャッジ日時 2023-08-19 17:20:09
合計ジャッジ時間 13,908 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,776 KB
testcase_01 AC 118 ms
55,656 KB
testcase_02 AC 118 ms
55,616 KB
testcase_03 AC 125 ms
55,592 KB
testcase_04 AC 126 ms
55,788 KB
testcase_05 AC 124 ms
55,704 KB
testcase_06 AC 125 ms
55,704 KB
testcase_07 AC 126 ms
55,760 KB
testcase_08 AC 126 ms
55,660 KB
testcase_09 AC 123 ms
55,652 KB
testcase_10 AC 735 ms
55,824 KB
testcase_11 AC 888 ms
55,900 KB
testcase_12 AC 733 ms
55,888 KB
testcase_13 AC 593 ms
55,520 KB
testcase_14 AC 842 ms
55,764 KB
testcase_15 AC 867 ms
55,516 KB
testcase_16 AC 671 ms
55,636 KB
testcase_17 AC 786 ms
55,888 KB
testcase_18 AC 890 ms
55,912 KB
testcase_19 AC 1,351 ms
55,980 KB
権限があれば一括ダウンロードができます

ソースコード

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