結果

問題 No.561 東京と京都
ユーザー しのっちしのっち
提出日時 2019-06-25 14:21:26
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 867 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 12,428 KB
最終ジャッジ日時 2023-09-05 03:09:21
合計ジャッジ時間 2,184 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 7 ms
12,252 KB
testcase_02 AC 7 ms
12,200 KB
testcase_03 AC 8 ms
12,260 KB
testcase_04 WA -
testcase_05 AC 8 ms
12,260 KB
testcase_06 AC 7 ms
12,288 KB
testcase_07 AC 7 ms
12,316 KB
testcase_08 AC 7 ms
12,272 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 7 ms
12,292 KB
testcase_13 WA -
testcase_14 AC 7 ms
12,240 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$location = "tokyo";
$income = 0;
list($workdays, $fare) = explode(" ", trim(fgets(STDIN)));
for ($i = 0; $i < $workdays; $i++) {
  list($salaries[$i]["tokyo"], $salaries[$i]["kyoto"]) = explode(" ", trim(fgets(STDIN)));
}
for ($i = 0; $i < $workdays; $i++) {
  // 現在地 東京
  if ($location == "tokyo") {
    if ($salaries[$i]["kyoto"] - $fare > $salaries[$i]["tokyo"]) {
      $income += $salaries[$i]["kyoto"] - $fare;
      $location = "kyoto";
    } else {
      $income += $salaries[$i]["tokyo"];
    }
  // 現在地 京都
  } else {
    if ($salaries[$i]["tokyo"] - $fare > $salaries[$i]["kyoto"]) {
      $income += $salaries[$i]["tokyo"] - $fare;
      $location = "tokyo";
    } else {
      $income += $salaries[$i]["kyoto"];
    }
  }
}

// 行った先で大きな差が発生してたらやり直ししないとダメ?
echo $income."\n";
0