結果
問題 | No.595 登山 |
ユーザー | te-sh |
提出日時 | 2017-11-11 00:13:33 |
言語 | D (dmd 2.106.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 517 bytes |
コンパイル時間 | 700 ms |
コンパイル使用メモリ | 88,324 KB |
実行使用メモリ | 13,512 KB |
最終ジャッジ日時 | 2023-09-03 16:50:45 |
合計ジャッジ時間 | 2,659 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 18 ms
5,732 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 1 ms
4,376 KB |
testcase_25 | AC | 1 ms
4,376 KB |
testcase_26 | AC | 47 ms
13,500 KB |
testcase_27 | AC | 33 ms
12,420 KB |
testcase_28 | AC | 35 ms
12,408 KB |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.to!(int[]), n = rd[0], p = rd[1].to!long; auto h = readln.split.to!(long[]); auto i = 0, j = 0, r = 0L, ans = 0L; while (i < n-1 && j < n-1) { if (h[j+1] >= h[j]) { r += min(h[j+1]-h[j], p); ++j; } else { ans += j == n-1 ? min(r, p) : min(r, p*2); r = 0L; while (j < n-1 && h[j] > h[j+1]) ++j; i = j; } } if (i < j) ans += min(r, p); writeln(ans); }