結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー AreTrashAreTrash
提出日時 2016-12-04 15:53:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 4,060 bytes
コンパイル時間 5,679 ms
コンパイル使用メモリ 110,408 KB
実行使用メモリ 30,972 KB
最終ジャッジ日時 2023-08-18 14:08:49
合計ジャッジ時間 6,837 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
23,132 KB
testcase_01 AC 81 ms
21,172 KB
testcase_02 AC 78 ms
21,240 KB
testcase_03 AC 85 ms
25,364 KB
testcase_04 AC 84 ms
25,388 KB
testcase_05 AC 90 ms
25,428 KB
testcase_06 AC 95 ms
25,476 KB
testcase_07 AC 87 ms
23,272 KB
testcase_08 AC 90 ms
25,208 KB
testcase_09 AC 95 ms
25,536 KB
testcase_10 AC 84 ms
23,304 KB
testcase_11 AC 86 ms
23,280 KB
testcase_12 AC 86 ms
25,244 KB
testcase_13 AC 94 ms
25,464 KB
testcase_14 AC 95 ms
27,716 KB
testcase_15 AC 85 ms
23,276 KB
testcase_16 AC 84 ms
23,276 KB
testcase_17 AC 85 ms
23,292 KB
testcase_18 AC 81 ms
23,120 KB
testcase_19 AC 104 ms
29,004 KB
testcase_20 AC 96 ms
25,592 KB
testcase_21 AC 85 ms
25,244 KB
testcase_22 AC 84 ms
23,268 KB
testcase_23 AC 87 ms
25,280 KB
testcase_24 AC 95 ms
27,372 KB
testcase_25 AC 102 ms
30,972 KB
testcase_26 AC 89 ms
23,176 KB
testcase_27 AC 88 ms
21,236 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.Linq;

namespace No447{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var L = sr.Next<int>(N);
            var T = sr.Next<int>();

            var contest = new Contest(L);
            for(var i = 0; i < T; i++){
                var name = sr.Next<string>();
                var number = sr.Next<string>();
                contest.Solve(name, number);
            }

            Console.WriteLine(string.Join("\n", contest.Result()));
            //---------------------------------
        }
    }

    public class Contest{
        private readonly List<Problem> _problems = new List<Problem>();
        private readonly Dictionary<string, Contestant> _contestants = new Dictionary<string, Contestant>();
        private int _count;

        public Contest(int[] levels){
            Array.ForEach(levels, l => _problems.Add(new Problem(l)));
        }

        public void Solve(string name, string number){
            if(!_contestants.ContainsKey(name)){
                _contestants.Add(name, new Contestant(_problems.Count));
            }
            var solver = _contestants[name];
            var num = number[0] - 'A';
            var point = _problems[num].Solve(solver);
            solver.Solve(num, point, _count++);
        }

        public string[] Result(){
            return _contestants
                .OrderByDescending(con => con.Value.Sum())
                .ThenBy(con => con.Value.Count)
                .Select((contestant, idx) => $"{idx + 1} {contestant.Key} {contestant.Value.Result()} {contestant.Value.Sum()}")
                .ToArray();
        }
    }

    public class Contestant{
        private readonly int[] _points;
        public int Count { private set; get; }

        public Contestant(int cnt){
            _points = new int[cnt];
        }

        public void Solve(int num, int point, int count){
            _points[num] = point;
            Count = count;
        }

        public int Sum(){
            return _points.Sum();
        }

        public string Result(){
            return string.Join(" ", _points);
        }
    }

    public class Problem{
        private readonly HashSet<Contestant> _solver = new HashSet<Contestant>();
        private readonly int _level;

        public Problem(int level){
            _level = level;
        }

        public int Solve(Contestant contestant){
            _solver.Add(contestant);
            return (int)Math.Floor(50 * _level + 50 * _level / (0.8 + 0.2 * _solver.Count));
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}
0