結果

問題 No.647 明太子
ユーザー ichibanshibori
提出日時 2018-09-20 00:26:59
言語 F#
(F# 4.0)
結果
MLE  
実行時間 -
コード長 1,597 bytes
コンパイル時間 12,783 ms
コンパイル使用メモリ 191,792 KB
実行使用メモリ 380,368 KB
最終ジャッジ日時 2024-07-18 08:23:48
合計ジャッジ時間 26,214 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 MLE * 1 -- * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (301 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/

ソースコード

diff #

let solve abLst xyLst =
    let m = List.length xyLst

    let chooseLst =
        seq abLst
        |> Seq.map (fun (a, b) -> Seq.init m (fun i -> (a, b, xyLst.[i])))
        |> Seq.concat
        |> Seq.map
            (fun (a, b, (i, x, y)) ->
                async {
                    return
                        if (x <= a) && (y >= b) then
                            Some(i)
                        else
                            None
                })
        |> Async.Parallel
        |> Async.RunSynchronously
        |> Array.toSeq
        |> Seq.choose id
        |> Seq.countBy id
        |> Seq.sortBy (fun (i, iCnt) -> (-iCnt, i))
        |> Seq.toList

    if List.isEmpty chooseLst then
        stdout.WriteLine(0)
    else
        let maxCnt = List.map (fun (i, iCnt) -> iCnt) chooseLst |> List.max
        List.filter (fun (i, iCnt) -> iCnt = maxCnt) chooseLst
        |> List.iter (fun (i, iCnt) -> printfn "%A" i)

let () =
    let n = stdin.ReadLine() |> int
    let abLst =
        seq {
            for i in 1..n do
                let ab =
                    stdin.ReadLine()
                    |> fun s -> s.Split()
                    |> fun arr -> (int arr.[0], int arr.[1])
                yield ab }
        |> Seq.toList
    let m = stdin.ReadLine() |> int
    let xyLst =
        seq {
            for i in 1..m do
                let xy =
                    stdin.ReadLine()
                    |> fun s -> s.Split()
                    |> fun arr -> (i, int arr.[0], int arr.[1])
                yield xy }
        |> Seq.toList

    solve abLst xyLst
0