結果

問題 No.365 ジェンガソート
ユーザー guriceringuricerin
提出日時 2020-01-31 11:35:56
言語 F#
(F# 4.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 1,100 bytes
コンパイル時間 7,605 ms
コンパイル使用メモリ 191,780 KB
実行使用メモリ 39,060 KB
最終ジャッジ日時 2023-10-17 08:16:12
合計ジャッジ時間 13,050 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
30,816 KB
testcase_01 AC 59 ms
30,816 KB
testcase_02 AC 60 ms
30,816 KB
testcase_03 AC 60 ms
30,816 KB
testcase_04 AC 60 ms
30,816 KB
testcase_05 AC 60 ms
30,816 KB
testcase_06 AC 61 ms
30,816 KB
testcase_07 AC 60 ms
30,816 KB
testcase_08 AC 59 ms
30,816 KB
testcase_09 AC 62 ms
30,816 KB
testcase_10 AC 61 ms
30,816 KB
testcase_11 AC 60 ms
30,816 KB
testcase_12 AC 61 ms
30,800 KB
testcase_13 AC 60 ms
30,800 KB
testcase_14 AC 61 ms
30,816 KB
testcase_15 AC 61 ms
30,800 KB
testcase_16 AC 126 ms
37,324 KB
testcase_17 AC 82 ms
38,528 KB
testcase_18 AC 63 ms
31,640 KB
testcase_19 AC 81 ms
38,500 KB
testcase_20 AC 68 ms
33,720 KB
testcase_21 AC 68 ms
33,144 KB
testcase_22 AC 79 ms
37,220 KB
testcase_23 AC 72 ms
34,808 KB
testcase_24 AC 78 ms
36,960 KB
testcase_25 AC 67 ms
33,052 KB
testcase_26 AC 74 ms
35,576 KB
testcase_27 AC 83 ms
38,924 KB
testcase_28 AC 74 ms
35,752 KB
testcase_29 AC 81 ms
38,180 KB
testcase_30 AC 75 ms
35,884 KB
testcase_31 AC 68 ms
33,440 KB
testcase_32 AC 69 ms
33,320 KB
testcase_33 AC 83 ms
38,820 KB
testcase_34 AC 66 ms
32,712 KB
testcase_35 AC 77 ms
37,020 KB
testcase_36 AC 82 ms
39,060 KB
testcase_37 AC 82 ms
39,048 KB
testcase_38 AC 83 ms
39,048 KB
testcase_39 AC 84 ms
39,048 KB
testcase_40 AC 82 ms
39,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (238 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let n = read int
    let A = reada int
    // 操作回数はnを超えない
    let mutable ans = n
    // 右から見てでかい数が降順に整列している個数を数える
    // 左から見て小さい数が整列しているかどうかはどうでもいい
    let mutable now, cnt = n, 0
    for i in n - 1 .. -1 .. 0 do
        let a = A.[i]
        if a = now then
            cnt <- cnt + 1
            now <- now - 1

    let ans = max 0 (ans - cnt)
    ans |> puts
    ()

main()
writer.Close()
0