結果

問題 No.345 最小チワワ問題
ユーザー phsplsphspls
提出日時 2020-03-28 11:12:29
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 102,952 KB
実行使用メモリ 23,364 KB
最終ジャッジ日時 2023-08-30 17:30:58
合計ジャッジ時間 5,278 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
21,208 KB
testcase_01 AC 51 ms
21,320 KB
testcase_02 AC 52 ms
21,216 KB
testcase_03 AC 51 ms
21,220 KB
testcase_04 AC 53 ms
21,300 KB
testcase_05 AC 53 ms
21,288 KB
testcase_06 AC 53 ms
23,272 KB
testcase_07 AC 54 ms
21,232 KB
testcase_08 AC 53 ms
21,360 KB
testcase_09 AC 52 ms
19,252 KB
testcase_10 AC 52 ms
21,236 KB
testcase_11 AC 52 ms
23,364 KB
testcase_12 AC 53 ms
21,252 KB
testcase_13 AC 53 ms
19,324 KB
testcase_14 AC 51 ms
23,344 KB
testcase_15 AC 50 ms
19,184 KB
testcase_16 AC 52 ms
23,272 KB
testcase_17 AC 51 ms
21,248 KB
testcase_18 AC 50 ms
19,260 KB
testcase_19 AC 51 ms
21,280 KB
testcase_20 AC 50 ms
21,328 KB
testcase_21 AC 52 ms
19,360 KB
testcase_22 AC 51 ms
21,256 KB
testcase_23 AC 51 ms
23,320 KB
testcase_24 AC 51 ms
21,172 KB
testcase_25 AC 51 ms
23,256 KB
testcase_26 AC 51 ms
21,220 KB
testcase_27 AC 52 ms
21,296 KB
testcase_28 AC 53 ms
23,360 KB
testcase_29 AC 52 ms
19,232 KB
testcase_30 AC 54 ms
23,348 KB
testcase_31 AC 55 ms
21,336 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

public class P0345 {
    public static void Main() {
        var s = Console.ReadLine().Trim().ToCharArray();
        var clist = new List<int>();
        var wlist = new List<int>();
        for(int i=0; i<s.Length; i++) {
            if(s[i] == 'c') clist.Add(i);
            if(s[i] == 'w') wlist.Add(i);
        }
        var result = s.Length + 1;
        for(int i=0; i<clist.Count(); i++) {
            var c = clist[i];
            var wcount = 0;
            for(int j=0; j<wlist.Count(); j++) {
                if(c < wlist[j]) wcount++;
                if(wcount == 2) {
                    result = Math.Min(result, wlist[j] - c + 1);
                    break;
                }
            }
        }
        if(result == s.Length + 1) {
            Console.WriteLine(-1);
        } else {
            Console.WriteLine(result);
        }
    }
}
0