結果

問題 No.90 品物の並び替え
ユーザー AreTrashAreTrash
提出日時 2016-04-14 11:48:57
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,699 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 113,248 KB
実行使用メモリ 33,404 KB
最終ジャッジ日時 2024-04-15 01:22:26
合計ジャッジ時間 5,763 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
27,080 KB
testcase_01 WA -
testcase_02 AC 30 ms
24,904 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 No90_2 {
    public class Program {
        public static void Main(string[] args) {
            var input = ReadList(Convert.ToInt32);
            var n = input[0];
            var m = input[1];

            var score = new List<int>[m];
            for(var i = 0; i < m; i++) {
                score[i] = ReadList(Convert.ToInt32);
            }

            var stack = new Stack<int>();
            var max = 0;

            Action<int> act = null;
            act = cnt => {
                for(var i = 0; i < n; i++) {
                    if(!stack.Contains(i)) {
                        stack.Push(i);
                    } else {
                        continue;
                    }
                    act(cnt + 1);
                    stack.Pop();
                }

                if(cnt == n) {
                    var tmpList = score.ToArray();
                    var point = 0;
                    foreach(var s in stack) {
                        for(var i = 0; i < m; i++){
                            if(tmpList[i][0] == s) point += tmpList[i][2];
                        }

                        for(var i = 0; i < m; i++){
                            if(tmpList[i][1] == s) tmpList[i][2] = 0;
                        }
                    }
                    max = Math.Max(max, point);
                }
            };
            act(0);

            Console.WriteLine(max);
        }

        public static List<TOutput> ReadList<TOutput>(Converter<string, TOutput> converter, char c = ' ') {
            return Console.ReadLine()?.Split(c).ToList().ConvertAll(converter);
        }
    }
}
0