結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー papinianuspapinianus
提出日時 2016-12-02 08:47:17
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 2,132 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 32,276 KB
実行使用メモリ 36,816 KB
最終ジャッジ日時 2024-05-05 17:32:48
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 42 ms
30,796 KB
testcase_02 AC 41 ms
31,092 KB
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
$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_NUMERIC, $lasts, 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