結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー toshiro_yanagi
提出日時 2018-06-04 02:27:53
言語 Nim
(2.2.6)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 449 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,160 ms
コンパイル使用メモリ 69,768 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-20 06:07:19
合計ジャッジ時間 2,983 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sequtils
let S = stdin.readLine
var progress, length = newSeqWith(0, 0)
var best = int.high

for i, s in S:
  case s:
    of 'c':
      progress.add(1)
      length.add(1)
    of 'w':
      if progress.len == 0: continue
      for i, v in progress:
        progress[i] += 1
        if progress[i] == 3:
          best = min(length[i], best)
    else:
      discard
  for i, v in length: length[i] += 1

echo [best, -1][int(best == int.high)]
0