結果
問題 | No.447 ゆきこーだーの雨と雪 (2) |
ユーザー | papinianus |
提出日時 | 2016-12-01 23:19:52 |
言語 | PHP (8.3.4) |
結果 |
AC
|
実行時間 | 489 ms / 2,000 ms |
コード長 | 2,656 bytes |
コンパイル時間 | 681 ms |
コンパイル使用メモリ | 18,508 KB |
実行使用メモリ | 25,048 KB |
最終ジャッジ日時 | 2023-08-18 11:47:27 |
合計ジャッジ時間 | 7,198 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
18,828 KB |
testcase_01 | AC | 15 ms
18,916 KB |
testcase_02 | AC | 15 ms
18,612 KB |
testcase_03 | AC | 47 ms
18,848 KB |
testcase_04 | AC | 47 ms
18,848 KB |
testcase_05 | AC | 303 ms
20,812 KB |
testcase_06 | AC | 286 ms
24,956 KB |
testcase_07 | AC | 179 ms
18,728 KB |
testcase_08 | AC | 156 ms
20,932 KB |
testcase_09 | AC | 399 ms
22,948 KB |
testcase_10 | AC | 31 ms
18,868 KB |
testcase_11 | AC | 64 ms
18,800 KB |
testcase_12 | AC | 82 ms
20,884 KB |
testcase_13 | AC | 324 ms
21,004 KB |
testcase_14 | AC | 489 ms
23,132 KB |
testcase_15 | AC | 73 ms
18,784 KB |
testcase_16 | AC | 31 ms
18,812 KB |
testcase_17 | AC | 61 ms
18,908 KB |
testcase_18 | AC | 25 ms
18,860 KB |
testcase_19 | AC | 345 ms
25,048 KB |
testcase_20 | AC | 480 ms
23,056 KB |
testcase_21 | AC | 71 ms
18,844 KB |
testcase_22 | AC | 76 ms
18,824 KB |
testcase_23 | AC | 105 ms
18,856 KB |
testcase_24 | AC | 295 ms
22,972 KB |
testcase_25 | AC | 383 ms
23,016 KB |
testcase_26 | AC | 170 ms
20,924 KB |
testcase_27 | AC | 147 ms
18,852 KB |
コンパイルメッセージ
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 = []; $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); $stars = $problems[$problemID]; $rank = $ranks[$problemID]++; $scores[$name]->setScore($problemID, calcScore($stars, $rank)); $board->upsert($name, $scores[$name]->getSum()); } foreach($board->getOrder() as $i => $name) { echo ($i+1).' '.$scores[$name]->toString().PHP_EOL; } function getID($char) { $alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'; return strpos($alpha, $char); } function calcScore($stars, $rank) { return floor((50 * $stars) + ((50 * $stars) / (0.8 + (0.2 * $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]]); $this->members = array_flip(array_column($this->table, 0)); } public function getOrder() { return array_column($this->table, 0); } 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; } }