結果

問題 No.723 2つの数の和
ユーザー 💕💖💞💕💖💞
提出日時 2018-08-04 12:17:58
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 454 bytes
コンパイル時間 14,136 ms
コンパイル使用メモリ 438,096 KB
実行使用メモリ 103,784 KB
最終ジャッジ日時 2024-04-30 19:07:45
合計ジャッジ時間 29,347 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 322 ms
56,912 KB
testcase_01 AC 323 ms
56,912 KB
testcase_02 AC 322 ms
56,948 KB
testcase_03 AC 737 ms
84,472 KB
testcase_04 AC 789 ms
95,548 KB
testcase_05 AC 771 ms
93,452 KB
testcase_06 AC 770 ms
95,460 KB
testcase_07 AC 625 ms
74,132 KB
testcase_08 AC 614 ms
76,484 KB
testcase_09 AC 761 ms
93,316 KB
testcase_10 AC 608 ms
74,404 KB
testcase_11 AC 492 ms
61,860 KB
testcase_12 AC 634 ms
78,448 KB
testcase_13 AC 740 ms
91,276 KB
testcase_14 AC 576 ms
68,172 KB
testcase_15 AC 618 ms
74,208 KB
testcase_16 AC 652 ms
80,332 KB
testcase_17 AC 734 ms
95,404 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 329 ms
57,032 KB
testcase_21 AC 331 ms
56,940 KB
testcase_22 AC 325 ms
56,972 KB
testcase_23 AC 758 ms
103,784 KB
testcase_24 AC 582 ms
70,164 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
         ^
Main.kt:2:8: warning: variable 'n' is never used
  val (n, x) = readLine()!!.split(" ").map(String::toInt)
       ^

ソースコード

diff #

fun main(args:Array<String>) {
  val (n, x) = readLine()!!.split(" ").map(String::toInt)
  val xs = readLine()!!.split(" ").map(String::toInt)
  val freq = xs.groupBy { it }.map { (k,vs) -> Pair(k, vs.size) }.toMap()
  val sets = xs.toSet()
  val keys = mutableListOf<Pair<Int,Int>>()
  for( s in sets.toList() ) {
    if( sets.contains(x-s) ) keys.add( Pair(s, x-s) )
  }
  keys.toList().map { (k, v) ->
   freq[k]!!*freq[v]!!
  }.sum().run(::println)
}
0