結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2019-09-08 01:52:21 |
言語 | Kotlin (2.1.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,654 bytes |
コンパイル時間 | 16,543 ms |
コンパイル使用メモリ | 451,756 KB |
実行使用メモリ | 60,060 KB |
最終ジャッジ日時 | 2024-06-27 14:50:22 |
合計ジャッジ時間 | 21,167 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 6 WA * 1 |
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'arr' is never used fun main(arr:Array<String>) { ^ Main.kt:22:68: warning: unnecessary non-null assertion (!!) on a non-null receiver of type List<Int> val w = target.sortedBy { taisen[it].count { it == 'o' } }!!.first() ^
ソースコード
import java.util.*fun main(arr:Array<String>) {val teamCount = readLine()!!.toInt()val taisen = (1..teamCount).map { readLine()!!.map { it }.toTypedArray() }.toTypedArray()taisen[0].indices.forEach {if(it > 0) {if(taisen[0][it] == '-') {taisen[0][it] = 'o'taisen[it][0] = 'x'}}}val queue = PriorityQueue<Int>(kotlin.Comparator { a, b -> taisen[b].count { it == 'o' }.compareTo(taisen[a].count{ it == 'o'}) })queue.addAll(1..(teamCount-1))while (queue.isNotEmpty()) {val l = queue.poll()val target = (1..teamCount - 1).filter { taisen[l][it] == '-' }if(target.isEmpty()) {continue}val w = target.sortedBy { taisen[it].count { it == 'o' } }!!.first()taisen[l][w] = 'x'taisen[w][l] = 'o'queue.add(l)}val ans = taisen.map { it.count { it == 'o' } }.distinct().sortedDescending().indexOf(taisen[0].count { it == 'o' }) + 1println(ans)}val dic = mutableMapOf<Int, MutableMap<Long, Long>>()val coins = (1..9).map { 111111 * it }.reversed().toTypedArray()fun getAns(idx:Int, target :Long):Long {if(target < coins.last() ) {return 1}if(idx > coins.lastIndex) {return 1}if(!dic.containsKey(idx)) {dic[idx] = mutableMapOf()}dic[idx]!![target]?.let { return it }var ans = 0.toLong()for(i in 0..target) {if(i*coins[idx] > target) {break}ans += getAns(idx + 1, target - i*coins[idx])}dic[idx]!![target] = ansreturn ans}