結果

問題 No.555 世界史のレポート
ユーザー GrenacheGrenache
提出日時 2017-08-12 11:51:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 935 bytes
コンパイル時間 3,140 ms
コンパイル使用メモリ 78,472 KB
実行使用メモリ 41,620 KB
最終ジャッジ日時 2024-04-21 06:10:15
合計ジャッジ時間 6,411 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
41,236 KB
testcase_01 AC 120 ms
41,360 KB
testcase_02 AC 120 ms
41,396 KB
testcase_03 AC 110 ms
40,248 KB
testcase_04 AC 109 ms
40,172 KB
testcase_05 AC 118 ms
41,160 KB
testcase_06 AC 116 ms
41,412 KB
testcase_07 AC 124 ms
41,288 KB
testcase_08 AC 111 ms
40,348 KB
testcase_09 AC 114 ms
40,340 KB
testcase_10 AC 137 ms
41,616 KB
testcase_11 AC 132 ms
41,472 KB
testcase_12 AC 135 ms
41,620 KB
testcase_13 AC 132 ms
41,496 KB
testcase_14 AC 124 ms
40,448 KB
testcase_15 AC 115 ms
40,236 KB
testcase_16 AC 120 ms
40,768 KB
testcase_17 AC 129 ms
41,556 KB
testcase_18 AC 127 ms
40,788 KB
testcase_19 AC 125 ms
40,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder555_1 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		final int INF = Integer.MAX_VALUE;

		int n = sc.nextInt();
		int c = sc.nextInt();
		int v = sc.nextInt();

		int[] dp = new int[n];
		Arrays.fill(dp, INF);
		dp[0] = 0;

		for (int i = 1; i < n; i++) {
			for (int j = 1; true; j++) {
				int next = i + i * j;
				next = Math.min(next, n);
				int cost = c + j * v;

				dp[next - 1] = Math.min(dp[next - 1], dp[i - 1] + cost);
				if (next == n) {
					break;
				}
			}
		}

		pr.println(dp[n - 1]);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0