結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー chike_plus
提出日時 2020-03-18 07:55:50
言語 F#
(F# 10.0)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
RE  
実行時間 -
コード長 718 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,083 ms
コンパイル使用メモリ 216,336 KB
実行使用メモリ 39,296 KB
最終ジャッジ日時 2026-05-24 20:12:39
合計ジャッジ時間 10,047 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 RE * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (165 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

let ``No.345 最小チワワ問題``() =
  
  let s = stdin.ReadLine()
  let Windexes =
    s
    |> Seq.mapi   (fun i c -> if c.Equals( 'w' ) then i + 1 else -1 )
    |> Seq.filter (fun i -> i >= 0)
    |> Seq.pairwise

  let res = 
    s
    |> Seq.mapi   (fun i c -> if c.Equals( 'c' ) then i else -1 )
    |> Seq.filter (fun i -> i >= 0)
    |> Seq.map ( fun n ->
        Windexes
        |> Seq.tryFind (fun (t1, t2) ->  n < t1 )
        |> function
          | Some (x1,x2)  -> x2 - n
          | None          -> -1
    )
  res
  |> Seq.max
  |> function
    | -1 -> -1
    |  _ -> res 
            |> Seq.filter( fun n -> n > 0)
            |> Seq.min
  |> stdout.WriteLine


``No.345 最小チワワ問題``()
0