結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2024-12-06 03:14:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 762 bytes |
コンパイル時間 | 479 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-12-06 03:14:18 |
合計ジャッジ時間 | 2,780 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 3 |
ソースコード
def main(): s = list(input()) cww_count = 0 cww_length = [] right_potential = [] for i in range(len(s)): if s[i] == "c": right_potential.append(i) elif s[i] == "w" and cww_count == 0 and right_potential: middle = i cww_count += 1 elif s[i] == "w" and cww_count == 1: left = i if right_potential and right_potential[0] < middle: right = max([x for x in right_potential if x < middle]) cww_length.append(left - right + 1) cww_count = 0 if cww_length == []: print(-1) else: sorted_length = sorted(cww_length) print(int(sorted_length[0])) if __name__ == "__main__": main()