結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-01-08 03:07:53 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 628 bytes |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-09-25 12:08:09 |
| 合計ジャッジ時間 | 1,898 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
def execute(arg):
ans = -1
cIndex = []
wIndex = []
for idx, s in enumerate(arg):
if(s == "c"):
cIndex.insert(0, idx)
if(s == "w"):
if(len(cIndex) > 0 and len(wIndex) > 0):
wLast = wIndex[0]
for cIdx in cIndex:
if(cIdx > wLast):
continue
length = idx - cIdx + 1
if(ans == -1 or ans > length):
ans = length
break
wIndex.insert(0, idx)
return ans
print(execute(input()))