結果
| 問題 | 
                            No.750 Frac #1
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-06-19 23:36:32 | 
| 言語 | PHP  (843.2)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 42 ms / 1,000 ms | 
| コード長 | 1,488 bytes | 
| コンパイル時間 | 188 ms | 
| コンパイル使用メモリ | 30,672 KB | 
| 実行使用メモリ | 31,264 KB | 
| 最終ジャッジ日時 | 2024-06-22 22:21:10 | 
| 合計ジャッジ時間 | 2,779 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 | 
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php
declare(strict_types=1);
$n = UtilIO::getInt();
$list = [];
while($n > 0) {
    $list[] = UtilIO::getString();
    $n--;
}
usort($list, function(string $a, string $b):int {
    [$aa, $ab] = array_map('intval', explode(" ", $a));
    [$ba, $bb] = array_map('intval', explode(" ", $b));
    return ($aa/$ab > $ba/$bb) ? -1 : (($aa/$ab < $ba/$bb) ? 1 : 0);
});
UtilIO::echo($list);
class UtilIO {
    protected static string $n = PHP_EOL;
    protected function __construct() { }
    public static function getString():string {
        return trim(fgets(STDIN));
    }
    public static function getInt():int {
        return intval(static::getString());
    }
    public static function getStringArray($separator = " "):array {
        return explode($separator, static::getString());
    }
    public static function getIntArray($separator = " "):array {
        return array_map('intval', static::getStringArray($separator));
    }
    public static function echo(mixed $value):void {
        if(is_string($value)) {
            echo static::toLine($value);
            return;
        }
        if(is_numeric($value)) {
            echo static::toLine(strval($value));
            return;
        }
        if(is_array($value)) {
            foreach($value as $v) {
                static::echo($v);
            }
            return;
        }
        var_export($value);
    }
    public static function toLine(string $str):string {
        return trim($str).static::$n;
    }
}