結果

問題 No.39 桁の数字を入れ替え
ユーザー papinianuspapinianus
提出日時 2016-07-29 17:40:02
言語 PHP
(8.3.4)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 356 bytes
コンパイル時間 1,413 ms
コンパイル使用メモリ 32,276 KB
実行使用メモリ 32,532 KB
最終ジャッジ日時 2024-04-10 05:29:36
合計ジャッジ時間 1,739 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
32,144 KB
testcase_01 AC 40 ms
32,276 KB
testcase_02 AC 40 ms
32,532 KB
testcase_03 AC 40 ms
32,344 KB
testcase_04 AC 40 ms
32,532 KB
testcase_05 AC 40 ms
32,276 KB
testcase_06 AC 41 ms
32,528 KB
testcase_07 AC 40 ms
32,276 KB
testcase_08 AC 40 ms
32,532 KB
testcase_09 AC 41 ms
32,344 KB
testcase_10 AC 40 ms
32,528 KB
testcase_11 AC 40 ms
32,404 KB
testcase_12 AC 40 ms
32,340 KB
testcase_13 AC 40 ms
32,400 KB
testcase_14 AC 41 ms
32,268 KB
testcase_15 AC 40 ms
32,400 KB
testcase_16 AC 40 ms
32,340 KB
testcase_17 AC 41 ms
32,532 KB
testcase_18 AC 40 ms
32,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$nums = str_split(trim(fgets(STDIN)));
$len = count($nums);
for($i = 0; $i < $len; $i++) {
    $cur = $nums[$i];
    $max = max(array_slice($nums,$i));
    if($cur < $max) {
        $maxes = array_keys($nums, $max);
        $nums[$i] = $max;
        $nums[$maxes[count($maxes)-1]] = $cur;
        break;
    }
}
echo implode("", $nums);
echo PHP_EOL;
0