結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー papinianuspapinianus
提出日時 2016-12-02 08:50:40
言語 PHP
(8.3.4)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 2,153 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 31,012 KB
実行使用メモリ 34,576 KB
最終ジャッジ日時 2024-05-05 17:32:59
合計ジャッジ時間 2,581 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
30,964 KB
testcase_01 AC 35 ms
30,800 KB
testcase_02 AC 37 ms
31,168 KB
testcase_03 AC 39 ms
31,000 KB
testcase_04 AC 38 ms
31,040 KB
testcase_05 AC 48 ms
33,292 KB
testcase_06 AC 53 ms
34,192 KB
testcase_07 AC 42 ms
31,760 KB
testcase_08 AC 46 ms
32,396 KB
testcase_09 AC 52 ms
33,872 KB
testcase_10 AC 38 ms
31,168 KB
testcase_11 AC 39 ms
31,120 KB
testcase_12 AC 41 ms
31,756 KB
testcase_13 AC 48 ms
33,292 KB
testcase_14 AC 53 ms
33,804 KB
testcase_15 AC 40 ms
30,992 KB
testcase_16 AC 35 ms
31,376 KB
testcase_17 AC 39 ms
31,272 KB
testcase_18 AC 36 ms
30,860 KB
testcase_19 AC 52 ms
34,576 KB
testcase_20 AC 53 ms
34,188 KB
testcase_21 AC 40 ms
31,248 KB
testcase_22 AC 38 ms
31,140 KB
testcase_23 AC 41 ms
31,372 KB
testcase_24 AC 47 ms
32,784 KB
testcase_25 AC 52 ms
33,936 KB
testcase_26 AC 44 ms
31,880 KB
testcase_27 AC 42 ms
31,504 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$problemCount = trim(fgets(STDIN));
$ranks = array_fill(0, $problemCount,1);
$problems = explode(' ', trim(fgets(STDIN)));
$posts = trim(fgets(STDIN));
$scores = [];
$memo = [];

for($i = 0;$posts;$posts--, $i++)
{
    list($name, $problemCode) = explode(' ', trim(fgets(STDIN)));
    if(!isset($scores[$name]))
    {
        $scores[$name] = new scorenote($name, $problemCount);
    }
    $problemID = getID($problemCode);

    $stars = $problems[$problemID];
    $rank = $ranks[$problemID]++;
    $scores[$name]->setScore($problemID, calcScore($stars, $rank), $i);
}
foreach($scores as $name => $score)
{
    $board[] = [$name, $score->getSum(), $score->getLast()];
    $sums[] = $score->getSum();
    $lasts[] = $score->getLast();
}
array_multisort($sums, SORT_DESC, SORT_NUMERIC, $lasts, SORT_ASC, SORT_NUMERIC, $board);
$i = 1;
foreach($board as $row)
{
    echo $i.' '.$scores[$row[0]]->toString().PHP_EOL;
    $i++;
}

function getID($char)
{
    $alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?';
    return strpos($alpha, $char);
}

function calcScore($stars, $rank)
{
    if(!isset($memo[$stars][$rank]))
    {
        $memo[$stars][$rank] = floor((50 * $stars) + ((50 * $stars) / (0.8 + (0.2 * $rank))));
    }
    return $memo[$stars][$rank];
}

class scorenote
{
    private $name;
    private $scores;
    private $sum;
    private $last;
    
    public function __construct($name, $count)
    {
        $this->name = $name;
        $this->scores = array_fill(0, $count, 0);
        $this->sum = 0;
        $this->last = 0;
    }
    
    public function getName()
    {
        return $this->name;
    }
    public function getSum()
    {
        return $this->sum;
    }
    public function getLast()
    {
        return $this->last;
    }
    
    public function toString()
    {
        $res = $this->name.' ';
        foreach($this->scores as $score)
        {
            $res .= $score.' ';
        }
        $res .= $this->sum;
        return $res;
    }
    
    public function setScore($problemId, $score, $last)
    {
        $this->scores[$problemId] = $score;
        $this->sum += $score;
        $this->last = $last;
    }
}
0