結果

問題 No.24 数当てゲーム
ユーザー ayaaya
提出日時 2019-07-24 15:53:29
言語 PHP
(8.3.4)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 895 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 18,664 KB
実行使用メモリ 18,960 KB
最終ジャッジ日時 2023-09-10 10:19:01
合計ジャッジ時間 892 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
18,888 KB
testcase_01 AC 17 ms
18,900 KB
testcase_02 AC 16 ms
18,940 KB
testcase_03 AC 16 ms
18,876 KB
testcase_04 AC 16 ms
18,856 KB
testcase_05 AC 15 ms
18,932 KB
testcase_06 AC 15 ms
18,648 KB
testcase_07 AC 15 ms
18,960 KB
testcase_08 AC 15 ms
18,776 KB
testcase_09 AC 16 ms
18,860 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
//No.24 数当てゲーム

$array=array_fill(0,10,null);
$N=trim(fgets(STDIN));
for($i=0;$i<$N;$i++){
  $line=trim(fgets(STDIN));
  $input= explode(" ",$line);
  if($input[4]=="NO"){
    for($x=0;$x<4;$x++){
      $array[$input[$x]]="NO";
    }

    //YESをもらった回数を$valueに入れていく

  }elseif($input[4]=="YES"){
    for($x=0;$x<4;$x++){
      $hantei=$array[$input[$x]];
      if(is_null($array[$input[$x]])){
        $array[$input[$x]]=1;
      }elseif(is_int($array[$input[$x]])){
        $array[$input[$x]]=$array[$input[$x]]+1;
      }
      
    }
  }
}
arsort($array);
foreach ($array as $key =>$value){

  if($value===4){
    echo $key;
    break;
  }elseif($value===3){
    echo $key;
    break;
  }elseif($value===2){
    echo $key;
    break;
  }else if($value===1){
    echo $key;
    break;
  }else if(is_null($value)){
    echo $key;
    break;
}

}

?>
0