結果

問題 No.664 超能力者Aと株価予測
ユーザー GrenacheGrenache
提出日時 2018-03-12 11:49:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 196 ms / 4,000 ms
コード長 1,063 bytes
コンパイル時間 3,179 ms
コンパイル使用メモリ 78,248 KB
実行使用メモリ 41,924 KB
最終ジャッジ日時 2024-04-25 00:42:16
合計ジャッジ時間 6,098 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
41,032 KB
testcase_01 AC 114 ms
41,424 KB
testcase_02 AC 106 ms
40,300 KB
testcase_03 AC 110 ms
41,404 KB
testcase_04 AC 113 ms
40,988 KB
testcase_05 AC 115 ms
41,244 KB
testcase_06 AC 126 ms
41,132 KB
testcase_07 AC 123 ms
41,364 KB
testcase_08 AC 146 ms
41,528 KB
testcase_09 AC 122 ms
41,312 KB
testcase_10 AC 177 ms
41,880 KB
testcase_11 AC 191 ms
41,884 KB
testcase_12 AC 196 ms
41,736 KB
testcase_13 AC 185 ms
41,924 KB
testcase_14 AC 105 ms
40,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder664 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();

		int[] a = new int[n + 1];
		for (int i = 0; i <= n; i++) {
			a[i] = sc.nextInt();
		}

		long[] dp = new long[n + 1];
		Arrays.fill(dp, k);
		long max = k;
		for (int l = 0; l < m; l++) {
			for (int i = n; i > 0; i--) {
				for (int j = i - 1; j >= 0; j--) {
					dp[i] = Math.max(dp[i], dp[j] / a[j] * a[i] + dp[j] % a[j]);
					dp[i] = Math.max(dp[i], dp[j]);
				}
			}

			for (int i = 1; i <= n; i++) {
				dp[i] = Math.max(dp[i], dp[i - 1]);
				max = Math.max(max, dp[i]);
			}
		}

		pr.println(max);
	}

	// ---------------------------------------------------
	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