結果
問題 | No.449 ゆきこーだーの雨と雪 (4) |
ユーザー | papinianus |
提出日時 | 2016-12-01 23:52:52 |
言語 | PHP (8.3.4) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,090 bytes |
コンパイル時間 | 3,151 ms |
コンパイル使用メモリ | 32,272 KB |
実行使用メモリ | 32,532 KB |
最終ジャッジ日時 | 2024-09-22 10:30:35 |
合計ジャッジ時間 | 11,241 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
32,528 KB |
testcase_01 | AC | 40 ms
32,404 KB |
testcase_02 | AC | 40 ms
32,400 KB |
testcase_03 | AC | 47 ms
32,404 KB |
testcase_04 | AC | 46 ms
32,272 KB |
testcase_05 | AC | 48 ms
32,400 KB |
testcase_06 | AC | 46 ms
32,212 KB |
testcase_07 | AC | 46 ms
32,272 KB |
testcase_08 | AC | 45 ms
32,532 KB |
testcase_09 | AC | 45 ms
32,400 KB |
testcase_10 | AC | 44 ms
32,400 KB |
testcase_11 | AC | 45 ms
32,528 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $problemCount = trim(fgets(STDIN)); $ranks = array_fill(0, $problemCount,1); $problems = explode(' ', trim(fgets(STDIN))); $posts = trim(fgets(STDIN)); $scores = []; $memo = []; $board = new scoreboard(); for(;$posts;$posts--) { list($name, $problemCode) = explode(' ', trim(fgets(STDIN))); if(!isset($scores[$name])) { $scores[$name] = new scorenote($name, $problemCount); } $problemID = getID($problemCode); if($problemID < 26) { $stars = $problems[$problemID]; $rank = $ranks[$problemID]++; $scores[$name]->setScore($problemID, calcScore($stars, $rank)); $board->upsert($name, $scores[$name]->getSum()); } else { echo $board->getRanking($name).PHP_EOL; } } // $board->extract($scores); 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 scoreboard { private $table; private $members; public function __construct() { $this->members = []; $this->table = []; } public function upsert($name, $sum) { if($this->inMember($name)) { array_splice($this->table, $this->members[$name], 1); } else { $this->members[$name] = count($this->members); } for($i = $this->members[$name];$i;$i--) { $prev = $i - 1; if($this->table[$prev][1] >= $sum) { break; } } array_splice($this->table, $i ,0, [[$name, $sum]]); $tableRows = count($this->table); for(;$i < $tableRows; $i++) { $this->members[$this->table[$i][0]] = $i; } } public function extract($persons) { foreach($this->table as $i => $row) { echo ($i+1).' '.$persons[$row[0]]->toString().PHP_EOL; } } public function getRanking($name) { return $this->members[$name] + 1; } private function inMember($name) { return isset($this->members[$name]); } } class scorenote { private $name; private $scores; private $sum; public function __construct($name, $count) { $this->name = $name; $this->scores = array_fill(0, $count, 0); $this->sum = 0; } public function getName() { return $this->name; } public function getSum() { return $this->sum; } public function toString() { $res = $this->name.' '; foreach($this->scores as $score) { $res .= $score.' '; } $res .= $this->sum; return $res; } public function setScore($problemId, $score) { $this->scores[$problemId] = $score; $this->sum += $score; } }