結果

問題 No.24 数当てゲーム
ユーザー 綾地寧々綾地寧々
提出日時 2015-05-05 12:22:45
言語 PHP
(8.3.4)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 964 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 18,840 KB
実行使用メモリ 18,976 KB
最終ジャッジ日時 2023-09-19 07:03:19
合計ジャッジ時間 959 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,936 KB
testcase_01 AC 16 ms
18,944 KB
testcase_02 AC 16 ms
18,892 KB
testcase_03 AC 16 ms
18,848 KB
testcase_04 AC 16 ms
18,936 KB
testcase_05 AC 16 ms
18,856 KB
testcase_06 AC 16 ms
18,852 KB
testcase_07 AC 16 ms
18,868 KB
testcase_08 AC 16 ms
18,896 KB
testcase_09 AC 16 ms
18,976 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$turn_max = trim(fgets(STDIN));
$pos_array = array();
$neg_array = array();
$yes_time = 0;
for ( $turn=0; $turn<$turn_max; $turn++ ) {
	list($num_array[0], $num_array[1], $num_array[2], $num_array[3], $ans) = explode(" ", trim(fgets(STDIN)));
	$num_array = array_unique($num_array);
	if ( strcmp($ans, 'YES') == 0 ) {
		$pos_array = array_merge($pos_array, $num_array);
		$yes_time++;
	}
	else {
		$neg_array = array_merge($neg_array, $num_array);
	}
}
$result = -1;
$neg_array = array_unique($neg_array);
if ( count($neg_array) >= 9 ) {
	for ( $needle=0; $needle<=9; $needle++ ) {
		if ( array_search($needle, $neg_array) === FALSE ) {
			$result = $needle;
			break;
		}
	}
}
if ( $result == -1 ) {
	$count_array = array_count_values($pos_array);
	$max_count = 0;
	foreach ( $count_array as $num => $count ) {
		if ( ($count == $yes_time) && (array_search($num, $neg_array) === FALSE) ) {
			$max_count++;
			$result = $num;
		}
	}
}
echo $result.PHP_EOL;
0