結果

問題 No.628 Tagの勢い
ユーザー ichibanshiboriichibanshibori
提出日時 2018-09-23 00:57:07
言語 F#
(F# 4.0)
結果
AC  
実行時間 360 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 13,563 ms
コンパイル使用メモリ 192,052 KB
実行使用メモリ 37,944 KB
最終ジャッジ日時 2024-04-16 20:17:55
合計ジャッジ時間 15,352 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 345 ms
36,888 KB
testcase_01 AC 359 ms
36,564 KB
testcase_02 AC 357 ms
36,884 KB
testcase_03 AC 356 ms
35,940 KB
testcase_04 AC 353 ms
35,568 KB
testcase_05 AC 349 ms
36,024 KB
testcase_06 AC 357 ms
36,660 KB
testcase_07 AC 356 ms
36,780 KB
testcase_08 AC 359 ms
36,492 KB
testcase_09 AC 352 ms
36,916 KB
testcase_10 AC 353 ms
36,504 KB
testcase_11 AC 350 ms
36,720 KB
testcase_12 AC 350 ms
37,828 KB
testcase_13 AC 357 ms
37,568 KB
testcase_14 AC 353 ms
37,944 KB
testcase_15 AC 354 ms
37,232 KB
testcase_16 AC 360 ms
37,276 KB
testcase_17 AC 349 ms
36,896 KB
testcase_18 AC 355 ms
36,740 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (440 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