結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
WagiHOH
|
| 提出日時 | 2016-07-08 11:21:30 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 552 bytes |
| コンパイル時間 | 750 ms |
| コンパイル使用メモリ | 99,584 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-12 03:37:25 |
| 合計ジャッジ時間 | 1,533 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
void main()
{
int[1000] lane, tasteMemo;
immutable n = readln.chomp.to!int;
readln.splitter.map!(to!int).copy(lane[]);
foreach (i, x; lane[0..n]) {
if (i < 2) {
tasteMemo[i] = x;
continue;
}
int max = 0;
foreach_reverse (j, y; tasteMemo[0..(i - 1)]) {
if (y > max) {
max = y;
}
}
tasteMemo[i] = x + max;
}
writeln(tasteMemo.reduce!max);
}
WagiHOH