結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー takepantakepan
提出日時 2016-11-19 21:50:14
言語 PHP
(8.3.4)
結果
AC  
実行時間 1,365 ms / 2,000 ms
コード長 2,251 bytes
コンパイル時間 926 ms
コンパイル使用メモリ 18,560 KB
実行使用メモリ 21,128 KB
最終ジャッジ日時 2023-08-18 03:46:15
合計ジャッジ時間 12,700 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,788 KB
testcase_01 AC 16 ms
18,872 KB
testcase_02 AC 15 ms
19,016 KB
testcase_03 AC 36 ms
18,996 KB
testcase_04 AC 32 ms
18,856 KB
testcase_05 AC 830 ms
20,880 KB
testcase_06 AC 900 ms
21,004 KB
testcase_07 AC 150 ms
18,892 KB
testcase_08 AC 380 ms
20,960 KB
testcase_09 AC 1,159 ms
20,988 KB
testcase_10 AC 40 ms
18,952 KB
testcase_11 AC 46 ms
18,912 KB
testcase_12 AC 162 ms
19,020 KB
testcase_13 AC 908 ms
21,072 KB
testcase_14 AC 1,358 ms
20,912 KB
testcase_15 AC 57 ms
18,976 KB
testcase_16 AC 86 ms
18,956 KB
testcase_17 AC 38 ms
19,000 KB
testcase_18 AC 25 ms
18,940 KB
testcase_19 AC 1,135 ms
21,128 KB
testcase_20 AC 1,365 ms
21,092 KB
testcase_21 AC 88 ms
18,960 KB
testcase_22 AC 51 ms
19,048 KB
testcase_23 AC 70 ms
18,936 KB
testcase_24 AC 441 ms
21,024 KB
testcase_25 AC 797 ms
21,016 KB
testcase_26 AC 150 ms
19,092 KB
testcase_27 AC 120 ms
19,016 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
    ini_set('error_reporting', E_ALL & ~E_NOTICE);

    // define('DEBUG', true);
    define('DEBUG', false);

    $ans = array();
    $Pcnt = array();

    fscanf(STDIN, "%d", $N);
    $L = explode(" ", trim(fgets(STDIN)));
    fscanf(STDIN, "%d", $T);
    for ($i = 0; $i < $T; $i++) {
        fscanf(STDIN, "%s %s", $Name, $P);
        $intP = getIntP($P);
        if (DEBUG) echo "{$P} {$intP}\n";
        $Pcnt[$intP]++;
        if (DEBUG) echo $Pcnt[$intP] . PHP_EOL;

        $score = floor(50 * $L[$intP] + 50 * $L[$intP] / (.8 + .2 * $Pcnt[$intP]));

        if (DEBUG) echo $score . PHP_EOL;

        $ans[$Name][$intP] = $score;
        $ans[$Name]['lastmod'] = $i;

    }

    if (DEBUG) var_dump($ans);

    foreach ($ans as $name => $v) {
        $score = 0;
        for ($i = 0; $i < count($L); $i++) {
            $score += $ans[$name][$i];
        }
        $ans[$name]['score'] = $score;
    }

    $board = array();
    foreach ($ans as $name => $v) {
        $base = $ans[$name];
        $base['name'] = $name;
        $board[] = $base;
    }

    if (DEBUG) var_dump($board);

    $people = count($board);
    for ($i = 0; $i < $people - 1; $i++) {
        for ($j = $i + 1; $j < $people; $j++) {
            $swap1 = $board[$i]['score'] < $board[$j]['score'];
            $swap2a = $board[$i]['score'] == $board[$j]['score'];
            $swap2b = $board[$i]['lastmod'] > $board[$j]['lastmod'];
            if ($swap1 || ($swap2a && $swap2b)) {
                $tmp = $board[$i];
                $board[$i] = $board[$j];
                $board[$j] = $tmp;
                // $board[$i][$personB] = $board[$j][$personB];
                // $board[$j][$personA] = $board[$i][$personA];
                // unset($board[$j][$personB]);
                // unset($board[$i][$personA]);

            }

        }
    }

    if (DEBUG) var_dump($board);

    for ($i = 0; $i < $people; $i++) {
        echo $i + 1;
        echo " ";
        echo $board[$i]['name'];
        echo " ";
        for ($j = 0; $j < count($L); $j++) {
            echo $board[$i][$j] ?: 0;
            echo " ";
        }
        echo $board[$i]['score'];
        echo PHP_EOL;
    }



    function getIntP($s) {
        return ord($s) - ord('A');
    }
0