結果
| 問題 |
No.1060 素敵な宝箱
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-27 10:28:59 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 984 ms / 2,000 ms |
| コード長 | 710 bytes |
| コンパイル時間 | 16,408 ms |
| コンパイル使用メモリ | 450,936 KB |
| 実行使用メモリ | 90,184 KB |
| 最終ジャッジ日時 | 2024-11-07 15:32:11 |
| 合計ジャッジ時間 | 32,540 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
コンパイルメッセージ
Main.kt:5:44: warning: 'sumBy((T) -> Int): Int' is deprecated. Use sumOf instead.
val gemSum = (0 until m).map{j -> gems.sumBy{it[j]}}
^
ソースコード
fun main() {
val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
val gems = Array(n){readLine()!!.trim().split(' ').map(String::toInt)}
val gemSum = (0 until m).map{j -> gems.sumBy{it[j]}}
gems.sortByDescending{it.zip(gemSum).map{(a, b) -> a.toLong() * b}.sum()}
val myScore = LongArray(m){0L}
val enjapma = LongArray(m){0L}
for (i in 0 until n) {
when (i and 1) {
0 -> for (j in 0 until m) {
myScore[j] += gems[i][j].toLong()
}
else -> for (j in 0 until m) {
enjapma[j] += gems[i][j].toLong()
}
}
}
println(myScore.map{it * it}.sum() - enjapma.map{it * it}.sum())
}