結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-02-18 16:58:09 |
| 言語 | Scala(Beta) (3.6.2) |
| 結果 |
AC
|
| 実行時間 | 3,825 ms / 5,000 ms |
| コード長 | 885 bytes |
| コンパイル時間 | 8,800 ms |
| コンパイル使用メモリ | 266,336 KB |
| 実行使用メモリ | 67,068 KB |
| 最終ジャッジ日時 | 2024-06-29 12:57:28 |
| 合計ジャッジ時間 | 25,339 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
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)
}
}
はむ吉🐹