結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー qazqaz
提出日時 2017-05-21 16:33:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 454 ms / 2,000 ms
コード長 3,310 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 115,804 KB
実行使用メモリ 25,600 KB
最終ジャッジ日時 2024-09-19 08:08:07
合計ジャッジ時間 8,994 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
20,608 KB
testcase_01 AC 46 ms
20,608 KB
testcase_02 AC 45 ms
20,352 KB
testcase_03 AC 110 ms
23,264 KB
testcase_04 AC 99 ms
22,756 KB
testcase_05 AC 317 ms
25,344 KB
testcase_06 AC 347 ms
24,960 KB
testcase_07 AC 237 ms
24,792 KB
testcase_08 AC 190 ms
24,748 KB
testcase_09 AC 388 ms
25,216 KB
testcase_10 AC 76 ms
22,656 KB
testcase_11 AC 140 ms
23,932 KB
testcase_12 AC 127 ms
24,660 KB
testcase_13 AC 323 ms
25,216 KB
testcase_14 AC 454 ms
25,344 KB
testcase_15 AC 145 ms
24,448 KB
testcase_16 AC 89 ms
23,680 KB
testcase_17 AC 133 ms
23,808 KB
testcase_18 AC 61 ms
21,632 KB
testcase_19 AC 438 ms
25,088 KB
testcase_20 AC 454 ms
25,600 KB
testcase_21 AC 121 ms
24,164 KB
testcase_22 AC 131 ms
23,504 KB
testcase_23 AC 208 ms
24,576 KB
testcase_24 AC 358 ms
24,960 KB
testcase_25 AC 449 ms
25,088 KB
testcase_26 AC 249 ms
24,772 KB
testcase_27 AC 238 ms
24,320 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

public class Program
{
    public static void Main() {
        var so = new Solver();
        so.Solve();
    }
}

public class Solver
{
    private readonly Reader reader;
    private readonly TextWriter writer;

    public Solver() {
        reader = new Reader(Console.In);
        writer = Console.Out;
    }

    public Solver(string input, string output) {
        reader = new Reader(new StreamReader(input));
        writer = new StreamWriter(output);
    }

    public void Solve() {
        int N = reader.RInt();
        int[] L = reader.RIntArray();
        int T = reader.RInt();

        var d = new List<KeyValuePair<string, int>>();
        for (int i = 0; i < T; i++) {
            d.Add(new KeyValuePair<string, int>(reader.RString(), GetQ(reader.String())));
        }

        var user = new List<User>();
        var answer = new List<int>();
        foreach (var item in d.Select((x, i) => new { x, i })) {
            answer.Add(item.x.Value);
            decimal c = (decimal)0.8 + (decimal)0.2 * answer.Count(x => x == item.x.Value);

            int b = L[item.x.Value];

            var u = user.FirstOrDefault(x => x.name == item.x.Key);
            if (u == null) {
                u = new User { name = item.x.Key };
                user.Add(u);
            }

            u.point.Add(item.x.Value, 50 * b + (int)(50 * b / c));
            u.lastAnswer = item.i;
            u.sumPoint = u.point.Select(x => x.Value).Sum();
        }

        var ans = user.OrderByDescending(x => x.sumPoint).ThenBy(x => x.lastAnswer);

        foreach (var item in ans.Select((x, i) => new { x, i })) {
            writer.Write(item.i + 1 + " " + item.x.name + " ");
            for (int i = 0; i < N; i++) {
                int p = item.x.point.FirstOrDefault(x => x.Key == i).Value;
                writer.Write(p + " ");
            }
            writer.WriteLine(item.x.sumPoint);
        }

        writer.Flush();
    }

    private int GetQ(string q) {
        string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        return s.IndexOf(q);
    }

    private class User
    {
        public string name;
        public Dictionary<int, int> point = new Dictionary<int, int>();
        public int sumPoint;
        public int lastAnswer;
    }
}

public class Reader
{
    private readonly TextReader reader;
    private readonly char separator = ' ';
    private string[] A = new string[0];
    private int i;

    public Reader(TextReader r) {
        reader = r;
    }

    public string String() { return Set(); }
    public int Int() { return int.Parse(Set()); }
    public long Long() { return long.Parse(Set()); }
    public decimal Decimal() { return decimal.Parse(Set()); }

    public string RString() { return RSet(); }
    public int RInt() { return int.Parse(RSet()); }
    public long RLong() { return long.Parse(RSet()); }
    public decimal RDecimal() { return decimal.Parse(RSet()); }

    public int[] RIntArray() { Read(); return A.Select(x => int.Parse(x)).ToArray(); }

    private void Read() {
        string line = reader.ReadLine();

        A = line.Split(separator);
        i = 0;
    }

    private string Set() { return A[i++]; }
    private string RSet() { Read(); return A[i++]; }
}
0