結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー takepantakepan
提出日時 2016-11-20 03:38:59
言語 PHP
(8.3.4)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,697 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 32,400 KB
実行使用メモリ 34,896 KB
最終ジャッジ日時 2024-05-05 10:32:58
合計ジャッジ時間 11,232 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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
    // $Tim = microtime(true);
    ini_set('error_reporting', E_ALL & ~E_NOTICE);
    ini_set('memory_limit', -1);

    $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');
        $Pcnt[$intP]++;

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

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

    }

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

    $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)) {
                list($board[$i], $board[$j]) = array($board[$j], $board[$i]);
            }

        }
    }

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

    echo $output;
    // echo (microtime(true) - $Tim) . PHP_EOL;
0