結果
問題 | No.29 パワーアップ |
ユーザー | バカらっく |
提出日時 | 2019-09-06 08:22:34 |
言語 | Kotlin (1.9.23) |
結果 |
RE
|
実行時間 | - |
コード長 | 793 bytes |
コンパイル時間 | 16,023 ms |
コンパイル使用メモリ | 423,212 KB |
実行使用メモリ | 53,884 KB |
最終ジャッジ日時 | 2023-09-05 17:43:06 |
合計ジャッジ時間 | 25,546 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 314 ms
53,176 KB |
testcase_01 | AC | 306 ms
53,164 KB |
testcase_02 | AC | 309 ms
53,064 KB |
testcase_03 | AC | 319 ms
53,504 KB |
testcase_04 | AC | 307 ms
53,140 KB |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'args' is never used fun main(args: Array<String>) { ^
ソースコード
import java.util.* fun main(args: Array<String>) { val count = readLine()!!.toInt() var items = mutableListOf<Int>() (1..count).forEach { items.addAll(readLine()!!.split(" ").map { it.toInt() }) } var ans = 0 while (items.size >= 2) { items.sortWith(kotlin.Comparator { a, b -> comp(a,b,items) }) val (a,b) = items.take(2) if(a == b) { ans++ (0..1).forEach { items.removeAt(0) } } else if(items.size >= 4) { ans = ans + items.size / 4 break } } println(ans) } fun comp(a:Int, b:Int, list : List<Int>):Int { val num1 = list.count { it == a } val num2 = list.count { it == b } if(num1 == num2) { return a.compareTo(b) } return num2.compareTo(num1) }