結果
問題 | No.3 ビットすごろく |
ユーザー | guricerin |
提出日時 | 2020-02-04 12:23:19 |
言語 | F# (.NET 7) |
結果 |
AC
|
実行時間 | 151 ms / 5,000 ms |
コード長 | 1,263 bytes |
コンパイル時間 | 3,839 ms |
コンパイル使用メモリ | 163,472 KB |
実行使用メモリ | 30,424 KB |
最終ジャッジ日時 | 2023-09-14 01:35:33 |
合計ジャッジ時間 | 10,334 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 149 ms
26,348 KB |
testcase_01 | AC | 148 ms
26,432 KB |
testcase_02 | AC | 147 ms
26,356 KB |
testcase_03 | AC | 149 ms
28,304 KB |
testcase_04 | AC | 149 ms
26,492 KB |
testcase_05 | AC | 150 ms
28,468 KB |
testcase_06 | AC | 150 ms
26,328 KB |
testcase_07 | AC | 149 ms
26,328 KB |
testcase_08 | AC | 149 ms
28,384 KB |
testcase_09 | AC | 150 ms
28,612 KB |
testcase_10 | AC | 150 ms
28,368 KB |
testcase_11 | AC | 150 ms
28,372 KB |
testcase_12 | AC | 150 ms
28,360 KB |
testcase_13 | AC | 149 ms
28,340 KB |
testcase_14 | AC | 149 ms
28,388 KB |
testcase_15 | AC | 149 ms
26,540 KB |
testcase_16 | AC | 151 ms
30,424 KB |
testcase_17 | AC | 149 ms
26,496 KB |
testcase_18 | AC | 150 ms
28,488 KB |
testcase_19 | AC | 150 ms
26,548 KB |
testcase_20 | AC | 150 ms
28,576 KB |
testcase_21 | AC | 149 ms
28,396 KB |
testcase_22 | AC | 151 ms
28,348 KB |
testcase_23 | AC | 149 ms
26,360 KB |
testcase_24 | AC | 149 ms
26,344 KB |
testcase_25 | AC | 150 ms
26,428 KB |
testcase_26 | AC | 150 ms
28,468 KB |
testcase_27 | AC | 149 ms
26,356 KB |
testcase_28 | AC | 149 ms
26,356 KB |
testcase_29 | AC | 150 ms
26,292 KB |
testcase_30 | AC | 149 ms
26,396 KB |
testcase_31 | AC | 150 ms
28,380 KB |
testcase_32 | AC | 150 ms
28,468 KB |
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0 Copyright (c) Microsoft Corporation. All Rights Reserved.
ソースコード
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 bitcount (a: int) = a |> fun x -> Convert.ToString(a, 2) |> fun x -> x.Replace("0", "") |> fun x -> x.Length let main() = let n = read int let len = 10100 let lim = Int32.MaxValue let dp = Array.init len (fun _ -> lim) dp.[0] <- 0 dp.[1] <- 1 for _ in 0 .. 10 do for i in 1 .. 10000 do let b = bitcount i let l = i - b let r = i + b let ok = dp.[i] <> lim if 1 <= l && l <= n && ok then dp.[l] <- min dp.[l] (dp.[i] + 1) if 1 <= r && r <= n && ok then dp.[r] <- min dp.[r] (dp.[i] + 1) if dp.[n] = lim then -1 else dp.[n] |> puts () main() writer.Close()