結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
30,928 KB
testcase_01 AC 38 ms
30,784 KB
testcase_02 AC 37 ms
30,836 KB
testcase_03 AC 41 ms
30,820 KB
testcase_04 AC 41 ms
30,984 KB
testcase_05 WA -
testcase_06 AC 40 ms
30,800 KB
testcase_07 AC 39 ms
30,756 KB
testcase_08 WA -
testcase_09 AC 38 ms
30,572 KB
testcase_10 AC 39 ms
30,816 KB
testcase_11 AC 41 ms
30,820 KB
testcase_12 AC 786 ms
30,784 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 40 ms
30,728 KB
testcase_17 AC 40 ms
30,860 KB
testcase_18 AC 45 ms
31,064 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 42 ms
31,096 KB
testcase_23 AC 43 ms
31,048 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 - $R[$i]) {
        if($first > $M - 1 - $R[$i]) {
          $first = $M - 1 - $R[$i];
          $index = $i;
          $temp = $M - 1 - $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