結果

問題 No.274 The Wall
ユーザー takeya_okinotakeya_okino
提出日時 2017-07-22 18:41:35
言語 PHP
(8.3.4)
結果
AC  
実行時間 849 ms / 2,000 ms
コード長 960 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 12,048 KB
実行使用メモリ 12,324 KB
最終ジャッジ日時 2023-09-04 02:28:04
合計ジャッジ時間 9,097 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
12,276 KB
testcase_01 AC 8 ms
12,240 KB
testcase_02 AC 10 ms
12,192 KB
testcase_03 AC 9 ms
12,324 KB
testcase_04 AC 7 ms
12,272 KB
testcase_05 AC 8 ms
12,232 KB
testcase_06 AC 8 ms
12,220 KB
testcase_07 AC 8 ms
12,252 KB
testcase_08 AC 8 ms
12,240 KB
testcase_09 AC 8 ms
12,296 KB
testcase_10 AC 7 ms
12,252 KB
testcase_11 AC 9 ms
12,296 KB
testcase_12 AC 849 ms
12,276 KB
testcase_13 AC 14 ms
12,164 KB
testcase_14 AC 123 ms
12,248 KB
testcase_15 AC 305 ms
12,280 KB
testcase_16 AC 397 ms
12,256 KB
testcase_17 AC 406 ms
12,300 KB
testcase_18 AC 298 ms
12,276 KB
testcase_19 AC 566 ms
12,272 KB
testcase_20 AC 654 ms
12,276 KB
testcase_21 AC 682 ms
12,256 KB
testcase_22 AC 728 ms
12,228 KB
testcase_23 AC 735 ms
12,272 KB
testcase_24 AC 727 ms
12,288 KB
testcase_25 AC 733 ms
12,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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[$j] == 0) {
      if($last < $L[$j]) {
        if($first > $L[$j]) {
          $first = $L[$j];
          $index = $j;
          $temp = $R[$j];
        } 
      }
      if($last < $M - 1 - $R[$j]) {
        if($first > $M - 1 - $R[$j]) {
          $first = $M - 1 - $R[$j];
          $index = $j;
          $temp = $M - 1 - $L[$j];
        }
      }
    }
  }
  if($index >= 0) {
    $last = $temp;
    $flg++;
    $choice[$index] = 1;
  } else {
    break;
  }
}
$ans = 'YES';
if($flg < $N) $ans = 'NO';
print($ans);
print("\n");
?>
0