結果
| 問題 |
No.447 ゆきこーだーの雨と雪 (2)
|
| ユーザー |
|
| 提出日時 | 2016-11-20 03:23:00 |
| 言語 | PHP (843.2) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,062 bytes |
| コンパイル時間 | 310 ms |
| コンパイル使用メモリ | 31,056 KB |
| 実行使用メモリ | 34,316 KB |
| 最終ジャッジ日時 | 2024-11-27 06:39:10 |
| 合計ジャッジ時間 | 12,320 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 25 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);
// define('DEBUG', true);
define('DEBUG', false);
$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');
if (DEBUG) echo "{$P} {$intP}\n";
$Pcnt[$intP]++;
if (DEBUG) echo $Pcnt[$intP] . PHP_EOL;
$score = floor(50 * $L[$intP] + 50 * $L[$intP] / (.8 + .2 * $Pcnt[$intP]));
if (DEBUG) echo $score . PHP_EOL;
$ans[$Name][$intP] = $score;
$ans[$Name]['lastmod'] = $i;
}
if (DEBUG) var_dump($ans);
foreach ($ans as $name => $v) {
$score = 0;
for ($i = 0; $i < $cntL; $i++) {
$score += $ans[$name][$i];
}
$ans[$name]['score'] = $score;
}
$board = array();
foreach ($ans as $name => $v) {
$base = $ans[$name];
$base['name'] = $name;
$board[] = $base;
}
if (DEBUG) var_dump($board);
$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)) {
$tmp = $board[$i];
$board[$i] = $board[$j];
$board[$j] = $tmp;
}
}
}
if (DEBUG) var_dump($board);
$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;