結果
| 問題 | 
                            No.628 Tagの勢い
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ooh_23
                         | 
                    
| 提出日時 | 2018-01-11 13:44:44 | 
| 言語 | C#(csc)  (csc 3.9.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,784 bytes | 
| コンパイル時間 | 842 ms | 
| コンパイル使用メモリ | 112,060 KB | 
| 実行使用メモリ | 27,196 KB | 
| 最終ジャッジ日時 | 2024-10-07 22:24:30 | 
| 合計ジャッジ時間 | 2,190 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 3 WA * 16 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Dictionary<string, int> tagScores = new Dictionary<string, int>();
            for(int i = 0; i < N; i++)
            {
                // データの読み取り
                Console.ReadLine();     // 入力データの番号が邪魔(使わないデータ)
                string[] ss = Console.ReadLine().Split();
                int M = int.Parse(ss[0]);      // 配列の1番目がタグの数
                int S = int.Parse(ss[1]);       // 配列の2番目がスコア
                string[] Tag = Console.ReadLine().Split();   // タグの読み取り
                // データをまとめる
                for (int tagNum = 0; tagNum < M; tagNum++)
                {
                    if (tagScores.ContainsKey(Tag[tagNum]))
                    {
                        // Dictionaryにtags[m]と同文字列のキーが既に存在する場合
                        tagScores[Tag[tagNum]] += S;
                    }
                    else {
                        // キーが無い場合
                        tagScores[Tag[tagNum]] = S;
                    }
                }
            }
            // タグとスコアのM分配列を用意する
            string[] tags = new string[tagScores.Count];
            int[] score = new int[tagScores.Count];
            // Dictionaryから配列に入れ直す
            int n = 0;
            foreach(string key in tagScores.Keys)
            {
                tags[n] = key;
                score[n] = tagScores[key];
                n++;
            }
            // 並べ替え
            for(int i = 0; i < score.Length; i++)
            {
                for(int k = i; k < score.Length - 2; k++)
                {
                    if (score[k] < score[k + 1] || score[k] == score[k + 1] && tags[k].CompareTo(tags[k + 1]) == 1)
                    {
                        int tmp = score[k];
                        score[k] = score[k + 1];
                        score[k + 1] = tmp;
                        string tmp2 = tags[k];
                        tags[k] = tags[k + 1];
                        tags[k + 1] = tmp2;
                    }
                }
            }
            // 出力処理
            int count = 10;
            if (count > tags.Length)
            {
                count = tags.Length;
            }
            for (int i = 0; i < count; i++)
            {
                Console.WriteLine(tags[i] + " " + score[i]);
            }
        }
    }
}
            
            
            
        
            
ooh_23