結果

問題 No.258 回転寿司(2)
ユーザー takeya_okinotakeya_okino
提出日時 2017-08-11 09:16:18
言語 PHP
(8.3.4)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 690 bytes
コンパイル時間 1,258 ms
コンパイル使用メモリ 30,448 KB
実行使用メモリ 34,192 KB
最終ジャッジ日時 2024-04-24 11:28:47
合計ジャッジ時間 6,466 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
34,192 KB
testcase_01 AC 39 ms
34,188 KB
testcase_02 AC 37 ms
31,884 KB
testcase_03 AC 34 ms
30,432 KB
testcase_04 AC 37 ms
31,244 KB
testcase_05 AC 35 ms
31,248 KB
testcase_06 AC 40 ms
33,424 KB
testcase_07 AC 35 ms
30,736 KB
testcase_08 AC 37 ms
31,244 KB
testcase_09 AC 37 ms
30,864 KB
testcase_10 AC 36 ms
30,612 KB
testcase_11 AC 37 ms
30,732 KB
testcase_12 AC 36 ms
30,992 KB
testcase_13 AC 36 ms
30,732 KB
testcase_14 AC 39 ms
32,908 KB
testcase_15 AC 37 ms
30,880 KB
testcase_16 AC 38 ms
30,640 KB
testcase_17 AC 37 ms
30,736 KB
testcase_18 AC 40 ms
33,548 KB
testcase_19 AC 34 ms
30,436 KB
testcase_20 AC 37 ms
32,140 KB
testcase_21 AC 40 ms
32,912 KB
testcase_22 AC 35 ms
30,716 KB
testcase_23 AC 37 ms
30,584 KB
testcase_24 AC 38 ms
30,648 KB
testcase_25 WA -
testcase_26 AC 39 ms
31,756 KB
testcase_27 AC 38 ms
30,864 KB
testcase_28 AC 40 ms
34,000 KB
testcase_29 AC 39 ms
30,864 KB
testcase_30 AC 38 ms
30,616 KB
testcase_31 AC 37 ms
30,632 KB
testcase_32 AC 38 ms
30,860 KB
testcase_33 AC 40 ms
32,656 KB
testcase_34 AC 37 ms
31,628 KB
testcase_35 AC 39 ms
31,372 KB
testcase_36 AC 35 ms
30,712 KB
testcase_37 AC 35 ms
30,496 KB
testcase_38 AC 38 ms
30,992 KB
testcase_39 AC 38 ms
30,856 KB
testcase_40 AC 40 ms
32,012 KB
testcase_41 AC 40 ms
32,652 KB
testcase_42 AC 38 ms
30,672 KB
testcase_43 AC 37 ms
30,356 KB
testcase_44 AC 40 ms
33,036 KB
testcase_45 AC 38 ms
32,268 KB
testcase_46 AC 37 ms
30,504 KB
testcase_47 AC 40 ms
32,272 KB
testcase_48 AC 37 ms
30,752 KB
testcase_49 AC 39 ms
30,736 KB
testcase_50 AC 34 ms
30,320 KB
testcase_51 AC 36 ms
31,632 KB
testcase_52 AC 38 ms
31,376 KB
testcase_53 AC 37 ms
30,356 KB
testcase_54 AC 40 ms
32,012 KB
testcase_55 AC 41 ms
33,936 KB
testcase_56 AC 37 ms
32,144 KB
testcase_57 AC 37 ms
30,608 KB
testcase_58 AC 38 ms
31,248 KB
testcase_59 AC 40 ms
33,676 KB
testcase_60 AC 36 ms
30,560 KB
testcase_61 AC 40 ms
32,656 KB
testcase_62 AC 36 ms
30,956 KB
testcase_63 AC 39 ms
31,760 KB
testcase_64 AC 40 ms
34,060 KB
testcase_65 AC 38 ms
32,144 KB
testcase_66 AC 35 ms
30,772 KB
testcase_67 AC 39 ms
32,652 KB
testcase_68 AC 38 ms
33,040 KB
testcase_69 AC 38 ms
32,656 KB
testcase_70 AC 35 ms
30,672 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$N = trim(fgets(STDIN));
$V = explode(" ", trim(fgets(STDIN)));
$dp = array();
$list = array();

$dp[0] = $V[0];
$list[0] = array(1);

if($V[0] >= $V[1]) {
  $dp[1] = $V[0];
  $list[1] = array(1);
} else {
  $dp[1] = $V[1];
  $list[1] = array(2);
}

for($i = 2; $i < $N; $i++) {
  if($dp[$i - 2] + $V[$i] >= $dp[$i - 1]) {
    $dp[$i] = $dp[$i - 2] + $V[$i];
    $b = $list[$i - 2];
    $b[] = $i + 1;
    $list[$i] = $b;
  } else {
    $dp[$i] = $dp[$i - 1];
    $list[$i] = $list[$i - 1];
  }
}

print($dp[$N - 1]);
print("\n");

$a = $list[$N - 1];
for($i = 0; $i < count($a); $i++) {
  print($a[$i]);
  if($i < count($a) - 1) {
    print(" ");
  } else {
    print("\n");
  }
}
?>
0