結果

問題 No.90 品物の並び替え
ユーザー skewesskewes
提出日時 2015-12-27 21:07:38
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,859 bytes
コンパイル時間 1,028 ms
コンパイル使用メモリ 111,180 KB
実行使用メモリ 25,216 KB
最終ジャッジ日時 2023-10-19 11:23:29
合計ジャッジ時間 1,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
25,216 KB
testcase_01 WA -
testcase_02 AC 32 ms
25,216 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 31 ms
25,216 KB
testcase_07 AC 31 ms
25,216 KB
testcase_08 AC 31 ms
25,216 KB
testcase_09 AC 32 ms
25,216 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 yukicoder
{
    class _090
    {
        static void Main()
        {
            int[] nm = Array.ConvertAll(Console.ReadLine().Split(' ')
                , x => int.Parse(x));
            int n = nm[0];
            int m = nm[1];
            Dictionary<string, int> mi = new Dictionary<string, int>();
            for (int i = 0; i < m; i++)
            {
                string[] sc = Console.ReadLine().Split(' ');
                mi.Add(sc[0] + sc[1], int.Parse(sc[2]));
            }
            int max = 0;

            List<int> item = new List<int>();
            item.Add(0);

            for (int i = 1; i < n; i++)
            {
                List<int> t = new List<int>();
                for (int j = 0; j < i + 1; j++)
                {
                    item.Insert(j, i);
                    t.Add(0);

                    for (int k = 0; k < i + 1; k++)
                    {
                        if (j == k)
                        {
                            continue;
                        }

                        string key;
                        if (j < k)
                        {
                            key = item[j].ToString() + item[k].ToString();
                        }
                        else
                        {
                            key = item[k].ToString() + item[j].ToString();
                        }

                        if (mi.Keys.Contains(key))
                        {
                            t[j] += mi[key];
                        }
                    }
                    item.Remove(i);
                }
                int tm = t.Max();
                max += tm;
                item.Insert(t.IndexOf(tm), i);
            }
            Console.WriteLine(max);
        }
    }
}
0