結果

問題 No.628 Tagの勢い
ユーザー ichibanshibori
提出日時 2018-09-23 00:57:07
言語 F#
(F# 4.0)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 9,073 ms
コンパイル使用メモリ 192,476 KB
実行使用メモリ 37,952 KB
最終ジャッジ日時 2024-10-07 22:57:09
合計ジャッジ時間 17,433 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (243 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 tagSeq =
    Seq.groupBy (fun (_, tag) -> tag) tagSeq
    |> Seq.map (fun (tag, mtSeq) -> (tag, Seq.sumBy (fun (m, _) -> m) mtSeq))
    |> Seq.sortBy (fun (tag, sumM) -> (-sumM, tag))
    |> Seq.mapi (fun i (tag, sumM) -> (i, tag, sumM))
    |> Seq.takeWhile (fun (i, _, _) -> i < 10)
    |> Seq.iter (fun (_, tag, sumM) -> printfn "%s %d" tag sumM)

let () =
    let n = stdin.ReadLine() |> int
    let tags =
        seq {
            for _ in 1..n do
                stdin.ReadLine() |> ignore
                let m =
                    stdin.ReadLine()
                    |> fun s -> s.Split()
                    |> fun arr -> int arr.[1]
                let tagArr =
                    stdin.ReadLine()
                    |> fun s -> s.Split()
                yield (Array.map (fun tag -> (m, tag)) tagArr)
        }
        |> Seq.concat
    solve tags
0