結果

問題 No.274 The Wall
ユーザー takeya_okinotakeya_okino
提出日時 2017-07-22 18:32:31
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 951 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 30,920 KB
実行使用メモリ 31,532 KB
最終ジャッジ日時 2024-04-17 15:56:03
合計ジャッジ時間 3,259 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
31,224 KB
testcase_01 AC 36 ms
31,416 KB
testcase_02 AC 36 ms
31,108 KB
testcase_03 AC 37 ms
31,040 KB
testcase_04 AC 35 ms
31,324 KB
testcase_05 WA -
testcase_06 AC 36 ms
31,452 KB
testcase_07 AC 36 ms
30,976 KB
testcase_08 AC 35 ms
31,492 KB
testcase_09 AC 38 ms
31,152 KB
testcase_10 AC 37 ms
31,464 KB
testcase_11 AC 40 ms
31,464 KB
testcase_12 AC 1,296 ms
31,112 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 36 ms
31,228 KB
testcase_17 AC 40 ms
30,932 KB
testcase_18 AC 39 ms
31,532 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 41 ms
30,928 KB
testcase_23 AC 36 ms
31,020 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++;
    $choice[$index] = 1;
  } else {
    break;
  }
}
$ans = 'YES';
if($flg < $N) $ans = 'NO';
print($ans);
print("\n");
?>
0