結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー qazqaz
提出日時 2017-05-21 16:33:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 472 ms / 2,000 ms
コード長 3,310 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 115,148 KB
実行使用メモリ 31,876 KB
最終ジャッジ日時 2023-10-19 12:03:37
合計ジャッジ時間 8,976 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
26,868 KB
testcase_01 AC 48 ms
26,868 KB
testcase_02 AC 48 ms
26,792 KB
testcase_03 AC 118 ms
28,920 KB
testcase_04 AC 107 ms
28,920 KB
testcase_05 AC 339 ms
31,692 KB
testcase_06 AC 356 ms
31,660 KB
testcase_07 AC 244 ms
31,264 KB
testcase_08 AC 205 ms
31,208 KB
testcase_09 AC 402 ms
31,772 KB
testcase_10 AC 80 ms
28,920 KB
testcase_11 AC 143 ms
28,920 KB
testcase_12 AC 130 ms
31,136 KB
testcase_13 AC 331 ms
31,672 KB
testcase_14 AC 459 ms
31,876 KB
testcase_15 AC 148 ms
28,920 KB
testcase_16 AC 87 ms
28,916 KB
testcase_17 AC 144 ms
28,928 KB
testcase_18 AC 64 ms
26,880 KB
testcase_19 AC 453 ms
31,724 KB
testcase_20 AC 472 ms
31,876 KB
testcase_21 AC 124 ms
28,920 KB
testcase_22 AC 136 ms
28,920 KB
testcase_23 AC 219 ms
31,040 KB
testcase_24 AC 366 ms
31,280 KB
testcase_25 AC 460 ms
31,488 KB
testcase_26 AC 262 ms
31,252 KB
testcase_27 AC 246 ms
31,124 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