結果
問題 |
No.118 門松列(2)
|
ユーザー |
![]() |
提出日時 | 2019-10-02 03:01:50 |
言語 | Kotlin (2.1.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 779 bytes |
コンパイル時間 | 15,306 ms |
コンパイル使用メモリ | 444,728 KB |
実行使用メモリ | 71,688 KB |
最終ジャッジ日時 | 2024-10-03 05:49:56 |
合計ジャッジ時間 | 25,189 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 WA * 22 |
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'arr' is never used fun main(arr:Array<String>) { ^ Main.kt:2:9: warning: variable 'itemCount' is never used val itemCount = readLine()!!.toInt() ^
ソースコード
fun main(arr:Array<String>) { val itemCount = readLine()!!.toInt() val items = readLine()!!.split(" ").map { it.toInt() }.let { a-> a.toSet().sorted().map { b-> b to a.count { it == b } } }.toMap() val keys = items.keys.toList() val count = items.keys.map { 0 }.toTypedArray() for(i in keys.indices) { if(i == 0) { count[0] = items[keys[0]]!! } else { count[i] = count[i-1] + items[keys[i]]!! } } var ans = 0L for(i in (0..keys.lastIndex - 2)) { for(j in (i+1..keys.lastIndex - 1)) { val remain = (count.last() - count[j]).toLong() val ptn = items[keys[i]]!!.toLong() * items[keys[j]]!!.toLong() * remain ans += ptn } } println(ans) }