結果

問題 No.564 背の順
ユーザー Too YoungToo Young
提出日時 2020-07-14 19:11:16
言語 PHP
(8.3.4)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 32,272 KB
実行使用メモリ 31,336 KB
最終ジャッジ日時 2024-04-29 07:24:21
合計ジャッジ時間 1,173 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
31,072 KB
testcase_01 AC 34 ms
31,336 KB
testcase_02 AC 37 ms
30,980 KB
testcase_03 AC 38 ms
31,132 KB
testcase_04 AC 35 ms
30,788 KB
testcase_05 AC 37 ms
31,108 KB
testcase_06 AC 38 ms
31,024 KB
testcase_07 AC 36 ms
31,044 KB
testcase_08 AC 34 ms
30,908 KB
testcase_09 AC 35 ms
31,180 KB
testcase_10 AC 38 ms
31,140 KB
testcase_11 AC 39 ms
31,120 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$row1 = explode(" ",trim(fgets(STDIN)));
$rowNum = $row1[1];
$myHeight = $row1[0];
$list[] = $myHeight;
for($i=0; $i < ($rowNum-1); $i++) {
    $row = explode(" ",trim(fgets(STDIN)));
    $list[] = $row[0];
}
rsort($list);
$listFlipped = array_flip($list);
$rank = $listFlipped[$myHeight] + 1;
$placeOf1 = substr($rank, -1);
$surfix = array("st","nd","rd","th");
if($placeOf1 > 3 || $placeOf1 == 0) {
    echo $rank.$surfix[3];
} else {
    echo $rank.$surfix[$placeOf1-1];
}
?>
0