結果

問題 No.90 品物の並び替え
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-02-18 16:58:09
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 3,953 ms / 5,000 ms
コード長 885 bytes
コンパイル時間 8,481 ms
コンパイル使用メモリ 261,616 KB
実行使用メモリ 66,376 KB
最終ジャッジ日時 2023-09-11 23:34:37
合計ジャッジ時間 26,455 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,040 ms
64,540 KB
testcase_01 AC 1,573 ms
66,148 KB
testcase_02 AC 1,000 ms
64,432 KB
testcase_03 AC 1,226 ms
65,284 KB
testcase_04 AC 1,213 ms
65,396 KB
testcase_05 AC 1,582 ms
66,204 KB
testcase_06 AC 1,636 ms
66,376 KB
testcase_07 AC 1,163 ms
65,336 KB
testcase_08 AC 1,014 ms
64,240 KB
testcase_09 AC 3,953 ms
66,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

object Main {
    def main(args: Array[String]): Unit = {
        val scanner = new java.util.Scanner(System.in)
        val n = scanner.nextInt
        val m = scanner.nextInt
        var table = Array.ofDim[Int](n, n)
        for (i <- 1 to m) {
            var item1 = scanner.nextInt
            var item2 = scanner.nextInt
            var score = scanner.nextInt
            table(item1)(item2) = score
        }
        var answer: Int = 0
        for (items <- (0 until n).permutations){
            var items_list = items.toList
            var current_sum: Int = 0
            for (item1 <- 0 until n; item2 <- 0 until n){
                if (items.indexOf(item1) < items.indexOf(item2)) {
                    current_sum += table(item1)(item2)
                }
            answer = scala.math.max(answer, current_sum)
            }
        }
        println(answer)
    }
}
0