結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー WagiHOHWagiHOH
提出日時 2017-01-30 20:20:52
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 1,551 bytes
コンパイル時間 1,993 ms
コンパイル使用メモリ 152,024 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 01:04:41
合計ジャッジ時間 4,608 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 73 ms
4,376 KB
testcase_06 AC 85 ms
4,376 KB
testcase_07 AC 34 ms
4,380 KB
testcase_08 AC 41 ms
4,376 KB
testcase_09 AC 107 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 11 ms
4,384 KB
testcase_12 AC 20 ms
4,376 KB
testcase_13 AC 84 ms
4,380 KB
testcase_14 AC 124 ms
4,380 KB
testcase_15 AC 13 ms
4,380 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 108 ms
4,380 KB
testcase_20 AC 124 ms
4,384 KB
testcase_21 AC 15 ms
4,380 KB
testcase_22 AC 12 ms
4,380 KB
testcase_23 AC 19 ms
4,380 KB
testcase_24 AC 69 ms
4,380 KB
testcase_25 AC 98 ms
4,380 KB
testcase_26 AC 34 ms
4,376 KB
testcase_27 AC 29 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
    }
}
0