結果
問題 | No.274 The Wall |
ユーザー |
![]() |
提出日時 | 2017-07-22 18:41:35 |
言語 | PHP (843.2) |
結果 |
AC
|
実行時間 | 812 ms / 2,000 ms |
コード長 | 960 bytes |
コンパイル時間 | 1,370 ms |
コンパイル使用メモリ | 32,400 KB |
実行使用メモリ | 32,656 KB |
最終ジャッジ日時 | 2024-06-22 02:20:54 |
合計ジャッジ時間 | 10,748 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?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"); ?>