結果

問題 No.664 超能力者Aと株価予測
ユーザー GrenacheGrenache
提出日時 2018-03-12 11:49:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 219 ms / 4,000 ms
コード長 1,063 bytes
コンパイル時間 3,276 ms
コンパイル使用メモリ 74,492 KB
実行使用メモリ 56,584 KB
最終ジャッジ日時 2023-08-07 06:34:51
合計ジャッジ時間 6,774 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,768 KB
testcase_01 AC 121 ms
56,052 KB
testcase_02 AC 122 ms
55,644 KB
testcase_03 AC 121 ms
55,636 KB
testcase_04 AC 122 ms
55,440 KB
testcase_05 AC 123 ms
55,804 KB
testcase_06 AC 132 ms
55,744 KB
testcase_07 AC 132 ms
56,008 KB
testcase_08 AC 162 ms
56,204 KB
testcase_09 AC 128 ms
56,032 KB
testcase_10 AC 197 ms
56,076 KB
testcase_11 AC 202 ms
56,112 KB
testcase_12 AC 219 ms
56,584 KB
testcase_13 AC 200 ms
56,004 KB
testcase_14 AC 120 ms
55,652 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