結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
|
提出日時 | 2016-08-29 23:22:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 448 bytes |
コンパイル時間 | 809 ms |
コンパイル使用メモリ | 109,024 KB |
実行使用メモリ | 27,832 KB |
最終ジャッジ日時 | 2024-11-14 06:49:21 |
合計ジャッジ時間 | 2,647 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 14 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; public class Program { public static void Main() { var S = Console.ReadLine(); int min = int.MaxValue; int w = 0; for (int i = 0; i < S.Length - 2; i++) { if (S[i] == 'c') { for (int j = i; j < S.Length; j++) { if (S[j] == 'w') { if (++w == 2) { min = Math.Min(min, j - i + 1); break; } } } } } Console.WriteLine(min < int.MaxValue ? min : -1); } }