結果
| 問題 |
No.664 超能力者Aと株価予測
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-10 11:23:29 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,054 bytes |
| コンパイル時間 | 806 ms |
| コンパイル使用メモリ | 119,112 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-13 00:19:11 |
| 合計ジャッジ時間 | 1,532 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 1 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1];
auto K = s[2];
auto A = (N+1).iota.map!(_ => readln.chomp.to!int).array;
auto dp = new int[][](N+1, M+1);
dp[0][0] = K;
foreach (i; 0..N) {
if ((i == 0 || A[i] <= A[i-1]) && A[i] <= A[i+1]) {
foreach (j; i+1..N+1) {
if (A[j] >= A[j-1] && (j == N || A[j] >= A[j+1])) {
foreach (k; 0..M) {
int stock = dp[i][k] / A[i];
int rest = dp[i][k] % A[i];
int gain = stock * A[j];
dp[j][k+1] = max(dp[j][k+1], rest + gain);
}
}
}
}
foreach (k; 0..M+1) {
dp[i+1][k] = max(dp[i+1][k], dp[i][k]);
}
}
dp[N].reduce!max.writeln;
}