結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
32,404 KB
testcase_01 AC 36 ms
32,400 KB
testcase_02 AC 38 ms
32,532 KB
testcase_03 AC 39 ms
32,396 KB
testcase_04 AC 35 ms
32,404 KB
testcase_05 WA -
testcase_06 AC 33 ms
32,400 KB
testcase_07 AC 34 ms
32,400 KB
testcase_08 AC 32 ms
32,148 KB
testcase_09 AC 35 ms
32,276 KB
testcase_10 AC 32 ms
32,404 KB
testcase_11 AC 32 ms
32,340 KB
testcase_12 AC 704 ms
32,400 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 34 ms
32,276 KB
testcase_17 AC 38 ms
32,400 KB
testcase_18 AC 35 ms
32,400 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 38 ms
32,144 KB
testcase_23 AC 32 ms
32,400 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[$j] == 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