結果

問題 No.628 Tagの勢い
ユーザー mbanmban
提出日時 2018-01-09 19:01:30
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 2,504 bytes
コンパイル時間 1,044 ms
コンパイル使用メモリ 109,184 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2024-04-16 20:03:48
合計ジャッジ時間 2,313 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
19,840 KB
testcase_01 AC 35 ms
19,456 KB
testcase_02 AC 35 ms
19,456 KB
testcase_03 AC 35 ms
19,584 KB
testcase_04 AC 30 ms
18,944 KB
testcase_05 AC 35 ms
19,712 KB
testcase_06 AC 35 ms
19,584 KB
testcase_07 AC 35 ms
19,584 KB
testcase_08 AC 34 ms
19,712 KB
testcase_09 AC 35 ms
19,712 KB
testcase_10 AC 36 ms
19,712 KB
testcase_11 AC 35 ms
19,712 KB
testcase_12 AC 39 ms
20,224 KB
testcase_13 AC 39 ms
20,096 KB
testcase_14 AC 39 ms
20,096 KB
testcase_15 AC 40 ms
20,096 KB
testcase_16 AC 36 ms
19,840 KB
testcase_17 AC 36 ms
19,584 KB
testcase_18 AC 36 ms
19,584 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;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            //Console.WriteLine(Next());
            return int.Parse(Next());
            //return 1;
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class HashMap<K, V> : Dictionary<K, V>
    {
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }

    class Program
    {
        HashMap<string, int> Hs = new HashMap<string, int>();

        public void Solve()
        {
            var sc = new Scanner();
            var n = sc.NextInt();
            for (int i = 0; i < n; i++)
            {
                sc.Next();
                sc.Next();
                var s = sc.NextInt();
                var tag = sc.Array();
                foreach (var ss in tag)
                {
                    Hs[ss] += s;
                }
            }
            var ans = Hs.ToArray();
            Array.Sort(ans, (a, b) =>
            {
                if (a.Value == b.Value)
                {
                    return a.Key.CompareTo(b.Key);
                }
                return -a.Value.CompareTo(b.Value);
            });
            for (int i = 0; i < Math.Min(10, ans.Length); i++)
            {
                var p = ans[i];
                Console.WriteLine($"{p.Key} {p.Value}");
            }
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}
0