結果

問題 No.345 最小チワワ問題
ユーザー curryudon08curryudon08
提出日時 2020-06-28 18:58:26
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 2,989 ms
コンパイル使用メモリ 103,660 KB
実行使用メモリ 22,560 KB
最終ジャッジ日時 2023-09-22 08:04:10
合計ジャッジ時間 5,746 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
18,492 KB
testcase_01 AC 54 ms
20,480 KB
testcase_02 AC 54 ms
20,620 KB
testcase_03 AC 53 ms
20,516 KB
testcase_04 AC 55 ms
20,488 KB
testcase_05 AC 54 ms
20,520 KB
testcase_06 AC 55 ms
18,572 KB
testcase_07 AC 57 ms
20,528 KB
testcase_08 AC 56 ms
22,472 KB
testcase_09 AC 55 ms
22,560 KB
testcase_10 AC 55 ms
18,508 KB
testcase_11 AC 56 ms
20,568 KB
testcase_12 AC 58 ms
20,576 KB
testcase_13 AC 60 ms
18,444 KB
testcase_14 AC 55 ms
20,352 KB
testcase_15 AC 54 ms
20,368 KB
testcase_16 AC 54 ms
20,432 KB
testcase_17 AC 54 ms
20,576 KB
testcase_18 AC 54 ms
20,424 KB
testcase_19 AC 54 ms
20,432 KB
testcase_20 AC 54 ms
20,500 KB
testcase_21 AC 57 ms
20,688 KB
testcase_22 AC 55 ms
20,412 KB
testcase_23 AC 57 ms
20,536 KB
testcase_24 AC 56 ms
20,508 KB
testcase_25 AC 55 ms
22,480 KB
testcase_26 AC 53 ms
20,440 KB
testcase_27 AC 53 ms
20,608 KB
testcase_28 AC 57 ms
20,488 KB
testcase_29 AC 53 ms
20,440 KB
testcase_30 AC 53 ms
18,448 KB
testcase_31 AC 54 ms
20,620 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace _0345
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var ans = int.MaxValue;
            for(var i = 0; i < s.Length; i++){
                if(s[i] == 'c'){
                    var cnt = 1;
                    var w = 0;
                    for(var j = i + 1; j < s.Length; j++){
                        cnt++;
                        if(s[j] == 'w'){
                            w++;
                            if(w == 2){
                                ans = Math.Min(ans,cnt);
                                break;
                            }
                        }
                    }
                }
            }

            Console.WriteLine(ans != int.MaxValue ? ans: -1);
        }
    }
}
0