結果

問題 No.723 2つの数の和
ユーザー taktak
提出日時 2019-02-27 14:02:27
言語 F#
(.NET 7)
結果
WA  
実行時間 -
コード長 516 bytes
コンパイル時間 5,393 ms
コンパイル使用メモリ 164,468 KB
実行使用メモリ 46,048 KB
最終ジャッジ日時 2023-09-05 09:15:59
合計ジャッジ時間 10,866 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
24,300 KB
testcase_01 AC 69 ms
22,376 KB
testcase_02 AC 69 ms
22,268 KB
testcase_03 AC 227 ms
41,720 KB
testcase_04 AC 271 ms
46,048 KB
testcase_05 AC 263 ms
44,156 KB
testcase_06 AC 273 ms
45,652 KB
testcase_07 AC 165 ms
36,152 KB
testcase_08 AC 178 ms
35,536 KB
testcase_09 AC 277 ms
44,116 KB
testcase_10 AC 162 ms
33,980 KB
testcase_11 AC 95 ms
27,548 KB
testcase_12 AC 192 ms
37,776 KB
testcase_13 AC 275 ms
43,292 KB
testcase_14 AC 127 ms
31,200 KB
testcase_15 AC 169 ms
37,180 KB
testcase_16 AC 210 ms
41,400 KB
testcase_17 AC 251 ms
45,764 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 68 ms
22,236 KB
testcase_21 AC 68 ms
20,296 KB
testcase_22 AC 69 ms
20,208 KB
testcase_23 AC 305 ms
43,896 KB
testcase_24 AC 142 ms
32,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System

let solve (a: int array) x =
  let count = a |> Array.countBy id
  let countKey = count |> Array.map fst
  let countMap = count |> Map.ofArray
  let pairNum key1 =
    let val1 = countMap.[key1]
    let key2 = x - key1
    Map.tryFind key2 countMap
    |> function
    | Some val2 -> val1 * val2
    | None -> 0
  countKey
  |> Array.map pairNum
  |> Array.sum

let R () = Console.ReadLine().Split() |> Array.map int

let N, X = 
  let t = R ()
  t.[0], t.[1]
let a = R()

solve a X
|> Console.WriteLine
0