結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー takepantakepan
提出日時 2016-11-20 03:20:04
言語 PHP
(8.3.4)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,978 bytes
コンパイル時間 4,374 ms
コンパイル使用メモリ 32,020 KB
実行使用メモリ 35,012 KB
最終ジャッジ日時 2024-05-05 10:31:37
合計ジャッジ時間 18,874 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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)));
    $cntL = count($L);
    fscanf(STDIN, "%d", $T);
    for ($i = 0; $i < $T; $i++) {
        fscanf(STDIN, "%s %s", $Name, $P);
        $intP = ord($P) - ord('A');
        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 < $cntL; $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;
            }

        }
    }

    if (DEBUG) var_dump($board);

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