結果

問題 No.274 The Wall
ユーザー takeya_okinotakeya_okino
提出日時 2017-07-22 17:36:01
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 926 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 32,276 KB
実行使用メモリ 32,532 KB
最終ジャッジ日時 2024-04-17 15:55:44
合計ジャッジ時間 4,029 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
31,496 KB
testcase_01 AC 38 ms
31,128 KB
testcase_02 AC 37 ms
31,272 KB
testcase_03 AC 38 ms
30,916 KB
testcase_04 AC 36 ms
31,040 KB
testcase_05 WA -
testcase_06 AC 38 ms
31,560 KB
testcase_07 AC 38 ms
31,148 KB
testcase_08 AC 38 ms
31,296 KB
testcase_09 AC 40 ms
31,100 KB
testcase_10 AC 41 ms
31,384 KB
testcase_11 AC 42 ms
31,048 KB
testcase_12 AC 1,339 ms
31,388 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 38 ms
31,112 KB
testcase_17 AC 44 ms
31,592 KB
testcase_18 AC 41 ms
31,236 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 47 ms
31,308 KB
testcase_23 AC 39 ms
31,412 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$array = explode(" ", trim(fgets(STDIN)));
$N = $array[0];
$M = $array[1];
$L = array();
$R = array();
for($i = 0; $i < $N; $i++) {
  $b = explode(" ", trim(fgets(STDIN)));
  $L[$i] = $b[0];
  $R[$i] = $b[1];
}
$choice = array();
for($i = 0; $i < $N; $i++) {
  $choice[$i] = 0;
}
$last = -1;
$flg = 0;
for($i = 0; $i < $N; $i++) {
  $index = -1;
  $first = $M;
  $temp = 0;
  for($j = 0; $j < $N; $j++) {
    if($choice[$i] == 0) {
      if($last < $L[$i]) {
        if($first > $L[$i]) {
          $first = $L[$i];
          $index = $i;
          $temp = $R[$i];
        } 
      }
      if($last < $M - 1 - $L[$i]) {
        if($first > $M - 1 - $L[$i]) {
          $first = $M - 1 - $L[$i];
          $index = $i;
          $temp = $L[$i];
        }
      }
    }
  }
  if($index >= 0) {
    $last = $temp;
    $flg++;
  } else {
    break;
  }
}
$ans = 'YES';
if($flg < $N) $ans = 'NO';
print($ans);
print("\n");
?>
0