提出 #76889500


ソースコード 拡げる

<?php

$n = intval(trim(fgets(STDIN)));
$a_arr = array_map('intval', explode(' ', trim(fgets(STDIN))));

$rtn = array($a_arr[0]);
$now = 0;
$i = 1;
while($i < $n){
    if(abs($a_arr[$i] - $rtn[$now]) === 1){
        $rtn[] = $a_arr[$i];
        $now++;
    }elseif($a_arr[$i] > $rtn[$now]){
        for($j=$rtn[$now]+1; $j<=$a_arr[$i]; $j++){
            $rtn[] = $j;
            $now++;
        }
    }else{
        for($j=$rtn[$now]-1; $j>=$a_arr[$i]; $j--){
            $rtn[] = $j;
            $now++;
        }
    }
    $i++;
}

print implode(' ', $rtn);

提出情報

提出日時
問題 D - Fill the Gaps
ユーザ hashiboso1002
言語 PHP (PHP 8.4.12)
得点 200
コード長 586 Byte
結果 AC
実行時間 22 ms
メモリ 22592 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 2
AC × 10
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 22 ms 22376 KiB
random_02.txt AC 15 ms 22324 KiB
random_03.txt AC 15 ms 22400 KiB
random_04.txt AC 15 ms 22364 KiB
random_05.txt AC 19 ms 22312 KiB
random_06.txt AC 17 ms 22592 KiB
random_07.txt AC 16 ms 22128 KiB
random_08.txt AC 15 ms 22124 KiB
sample_01.txt AC 15 ms 22292 KiB
sample_02.txt AC 14 ms 22080 KiB