結果

問題 No.370 道路の掃除
ユーザー takepantakepan
提出日時 2016-05-13 23:40:55
言語 PHP
(8.3.4)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 320 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 32,020 KB
実行使用メモリ 32,656 KB
最終ジャッジ日時 2024-04-15 17:19:23
合計ジャッジ時間 3,006 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
32,400 KB
testcase_01 AC 39 ms
32,396 KB
testcase_02 AC 38 ms
32,404 KB
testcase_03 AC 38 ms
32,276 KB
testcase_04 AC 38 ms
32,272 KB
testcase_05 AC 38 ms
32,400 KB
testcase_06 AC 37 ms
32,380 KB
testcase_07 AC 37 ms
32,404 KB
testcase_08 AC 38 ms
32,276 KB
testcase_09 AC 39 ms
32,344 KB
testcase_10 AC 39 ms
32,400 KB
testcase_11 AC 39 ms
32,400 KB
testcase_12 AC 39 ms
32,400 KB
testcase_13 AC 38 ms
32,396 KB
testcase_14 AC 38 ms
32,404 KB
testcase_15 AC 38 ms
32,400 KB
testcase_16 AC 38 ms
32,272 KB
testcase_17 AC 39 ms
32,400 KB
testcase_18 AC 37 ms
32,400 KB
testcase_19 AC 38 ms
32,216 KB
testcase_20 AC 39 ms
32,272 KB
testcase_21 AC 38 ms
32,400 KB
testcase_22 AC 38 ms
32,400 KB
testcase_23 AC 38 ms
32,404 KB
testcase_24 AC 38 ms
32,216 KB
testcase_25 AC 38 ms
32,532 KB
testcase_26 AC 38 ms
32,400 KB
testcase_27 AC 37 ms
32,276 KB
testcase_28 AC 38 ms
32,404 KB
testcase_29 AC 37 ms
32,528 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

$D = array();
$ans = PHP_INT_MAX;

fscanf(STDIN, "%d %d",$N, $M);
for ($i = 0; $i < $M; $i++) {
    fscanf(STDIN, "%d", $D[$i]);
}
for ($i = 0; $i < $M - $N + 1; $i++) {
    $diff = $D[$i + $N - 1] - $D[$i];
    $diff += min(abs($D[$i + $N - 1]), abs($D[$i]));
    $ans = min($ans, $diff);
}
echo $ans . PHP_EOL;
0