結果
問題 | No.90 品物の並び替え |
ユーザー | はむ吉🐹 |
提出日時 | 2016-02-18 17:04:38 |
言語 | Scala(Beta) (3.4.0) |
結果 |
AC
|
実行時間 | 2,336 ms / 5,000 ms |
コード長 | 889 bytes |
コンパイル時間 | 9,197 ms |
コンパイル使用メモリ | 254,448 KB |
実行使用メモリ | 66,736 KB |
最終ジャッジ日時 | 2023-09-11 23:36:01 |
合計ジャッジ時間 | 24,972 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,053 ms
64,276 KB |
testcase_01 | AC | 1,489 ms
66,136 KB |
testcase_02 | AC | 1,035 ms
64,864 KB |
testcase_03 | AC | 1,278 ms
64,588 KB |
testcase_04 | AC | 1,292 ms
64,712 KB |
testcase_05 | AC | 1,506 ms
66,736 KB |
testcase_06 | AC | 1,491 ms
66,088 KB |
testcase_07 | AC | 1,157 ms
64,592 KB |
testcase_08 | AC | 1,036 ms
64,292 KB |
testcase_09 | AC | 2,336 ms
66,372 KB |
ソースコード
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 idxs = (0 until n).map(items.indexOf(_)).toList var current_sum: Int = 0 for (item1 <- 0 until n; item2 <- 0 until n){ if (idxs(item1) < idxs(item2)) { current_sum += table(item1)(item2) } answer = scala.math.max(answer, current_sum) } } println(answer) } }