結果
| 問題 |
No.447 ゆきこーだーの雨と雪 (2)
|
| ユーザー |
WagiHOH
|
| 提出日時 | 2017-01-30 20:20:52 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 142 ms / 2,000 ms |
| コード長 | 1,551 bytes |
| コンパイル時間 | 2,206 ms |
| コンパイル使用メモリ | 151,376 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-12 06:44:16 |
| 合計ジャッジ時間 | 4,536 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
import std.stdio;
import std.algorithm;
import std.conv;
import std.math : floor;
import std.string : chomp;
int calcScore(int level, int rank)
{
return cast(int)floor(50 * level + 50 * level / (0.8 + 0.2 * rank));
}
void main(string[] args)
{
immutable n = readln.chomp.to!int;
int[26] levels;
readln.splitter.map!(to!int).copy(levels[]);
struct Player { string name; int score; }
Player[] players;
string[][26] log;
foreach (i; 0..readln.chomp.to!int) {
auto line = readln.chomp;
auto name = line[0..($ - 2)];
auto problemNo = line[$ - 1] - 'A';
log[problemNo] ~= name;
immutable score = calcScore(levels[problemNo], cast(int)log[problemNo].length);
auto j = players[].countUntil!"a.name == b"(name);
if (j >= 0) {
players[j].score += score;
} else {
players ~= Player(name, score);
j = players.length - 1;
}
const t = players[j];
while (j > 0 && t.score > players[j - 1].score) {
players[j] = players[j - 1];
--j;
}
players[j] = t;
}
foreach (rank, player; players) {
writef("%s %s ", rank + 1, player.name);
foreach (problemNo; 0..n) {
immutable i = log[problemNo].countUntil(player.name);
int score = 0;
if (i >= 0) {
score = calcScore(levels[problemNo], cast(int)i + 1);
}
write(score, " ");
}
writeln(player.score);
}
}
WagiHOH