結果

問題 No.1110 好きな歌
ユーザー ikdikd
提出日時 2020-07-10 23:40:10
言語 F#
(F# 4.0)
結果
AC  
実行時間 1,123 ms / 5,000 ms
コード長 532 bytes
コンパイル時間 7,557 ms
コンパイル使用メモリ 207,000 KB
実行使用メモリ 66,096 KB
最終ジャッジ日時 2024-04-20 00:27:24
合計ジャッジ時間 43,763 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
35,396 KB
testcase_01 AC 298 ms
34,428 KB
testcase_02 AC 353 ms
35,384 KB
testcase_03 AC 305 ms
34,608 KB
testcase_04 AC 295 ms
33,836 KB
testcase_05 AC 296 ms
34,476 KB
testcase_06 AC 294 ms
34,472 KB
testcase_07 AC 295 ms
34,580 KB
testcase_08 AC 298 ms
35,260 KB
testcase_09 AC 297 ms
34,716 KB
testcase_10 AC 296 ms
33,984 KB
testcase_11 AC 306 ms
35,264 KB
testcase_12 AC 315 ms
35,268 KB
testcase_13 AC 308 ms
35,144 KB
testcase_14 AC 308 ms
35,040 KB
testcase_15 AC 297 ms
35,276 KB
testcase_16 AC 298 ms
35,024 KB
testcase_17 AC 300 ms
34,652 KB
testcase_18 AC 296 ms
34,888 KB
testcase_19 AC 302 ms
34,816 KB
testcase_20 AC 312 ms
34,556 KB
testcase_21 AC 302 ms
35,448 KB
testcase_22 AC 301 ms
34,552 KB
testcase_23 AC 301 ms
34,636 KB
testcase_24 AC 784 ms
59,896 KB
testcase_25 AC 843 ms
60,344 KB
testcase_26 AC 605 ms
59,148 KB
testcase_27 AC 859 ms
60,628 KB
testcase_28 AC 648 ms
59,632 KB
testcase_29 AC 992 ms
64,984 KB
testcase_30 AC 596 ms
59,216 KB
testcase_31 AC 482 ms
50,400 KB
testcase_32 AC 1,022 ms
65,380 KB
testcase_33 AC 642 ms
59,108 KB
testcase_34 AC 768 ms
59,916 KB
testcase_35 AC 1,069 ms
65,056 KB
testcase_36 AC 383 ms
41,192 KB
testcase_37 AC 517 ms
52,612 KB
testcase_38 AC 940 ms
65,068 KB
testcase_39 AC 793 ms
59,848 KB
testcase_40 AC 877 ms
62,888 KB
testcase_41 AC 348 ms
38,584 KB
testcase_42 AC 1,013 ms
65,116 KB
testcase_43 AC 931 ms
65,296 KB
testcase_44 AC 1,068 ms
65,248 KB
testcase_45 AC 1,103 ms
65,180 KB
testcase_46 AC 1,070 ms
66,096 KB
testcase_47 AC 1,095 ms
65,248 KB
testcase_48 AC 1,049 ms
65,060 KB
testcase_49 AC 1,031 ms
65,132 KB
testcase_50 AC 1,120 ms
65,460 KB
testcase_51 AC 1,096 ms
65,584 KB
testcase_52 AC 1,080 ms
65,260 KB
testcase_53 AC 1,123 ms
65,252 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (222 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
/home/judge/data/code/Main.fs(16,9): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj]
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

open System

let lowerbound (a: int array) (x: int) =
    // a.[ok] <= x
    let rec f ok ng =
        if ng - ok = 1 then
            ok
        else
            let mid = (ok + ng) / 2
            if a.[mid] <= x then f mid ng else f ok mid

    f -1 a.Length

[<EntryPoint>]
let main _ =
    let [| n; d |] = stdin.ReadLine().Split() |> Array.map int

    let a =
        [| for _ in 1 .. n -> stdin.ReadLine() |> int |]

    let b = a |> Array.sort

    a |> Array.iter (fun x -> printfn "%d" <| 1 + lowerbound b (x - d))
    0
0