結果
問題 | No.723 2つの数の和 |
ユーザー | tak |
提出日時 | 2019-02-27 16:32:42 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 360 ms / 2,000 ms |
コード長 | 1,773 bytes |
コンパイル時間 | 9,806 ms |
コンパイル使用メモリ | 195,340 KB |
実行使用メモリ | 68,480 KB |
最終ジャッジ日時 | 2024-06-23 05:17:00 |
合計ジャッジ時間 | 11,599 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
30,080 KB |
testcase_01 | AC | 55 ms
30,080 KB |
testcase_02 | AC | 54 ms
30,336 KB |
testcase_03 | AC | 241 ms
62,956 KB |
testcase_04 | AC | 282 ms
63,348 KB |
testcase_05 | AC | 257 ms
63,232 KB |
testcase_06 | AC | 263 ms
63,232 KB |
testcase_07 | AC | 176 ms
58,624 KB |
testcase_08 | AC | 183 ms
59,132 KB |
testcase_09 | AC | 278 ms
63,616 KB |
testcase_10 | AC | 173 ms
58,880 KB |
testcase_11 | AC | 77 ms
36,588 KB |
testcase_12 | AC | 204 ms
62,708 KB |
testcase_13 | AC | 275 ms
63,488 KB |
testcase_14 | AC | 139 ms
50,048 KB |
testcase_15 | AC | 177 ms
58,732 KB |
testcase_16 | AC | 228 ms
63,104 KB |
testcase_17 | AC | 257 ms
63,232 KB |
testcase_18 | AC | 87 ms
44,288 KB |
testcase_19 | AC | 104 ms
45,824 KB |
testcase_20 | AC | 56 ms
30,464 KB |
testcase_21 | AC | 55 ms
30,336 KB |
testcase_22 | AC | 55 ms
30,208 KB |
testcase_23 | AC | 360 ms
68,480 KB |
testcase_24 | AC | 140 ms
53,888 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (271 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
open System open System.Text type IO() = let size = 1 <<< 12 let stream = Console.OpenStandardInput() let buffer = Array.zeroCreate size let ``!`` = byte '!' let ``~`` = byte '~' let mutable bufferPtr = 0 let hasNextByte = let mutable bufferLen = 0 fun () -> if bufferPtr < bufferLen then true else bufferPtr <- 0 bufferLen <- stream.Read(buffer, 0, size) bufferLen > 0 let readByte() = if hasNextByte() then let r = buffer.[bufferPtr] bufferPtr <- bufferPtr + 1 r else failwith "error" let isAscii c = ``!`` <= c && c <= ``~`` let nextCharByte() = let rec f() = let b = readByte() if isAscii b then b else f() f() let next() = let rec f (sb: StringBuilder) = let c = match sb.Length with | 0 -> nextCharByte() | _ -> readByte() if isAscii c then c |> char |> sb.Append |> f else sb f <| new StringBuilder() |> fun x -> x.ToString() member __.string() = next() member __.char() = nextCharByte() |> char member __.int() = next() |> int member __.int64() = next() |> int64 member __.float() = next() |> float let solve a 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] |> int64 let key2 = x - key1 Map.tryFind key2 countMap |> function | Some val2 -> val1 * (int64 val2) | None -> 0L countKey |> Array.map pairNum |> Array.sum let io = new IO() let N, X = let a = io.int() let b = io.int() a, b let a = let t = Array.zeroCreate N for i in 0 .. (N - 1) do t.[i] <- io.int() t solve a X |> Console.WriteLine