結果

問題 No.345 最小チワワ問題
ユーザー t8m8⛄️t8m8⛄️
提出日時 2016-02-26 22:32:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 941 bytes
コンパイル時間 5,213 ms
コンパイル使用メモリ 84,020 KB
実行使用メモリ 57,996 KB
最終ジャッジ日時 2023-10-26 03:29:11
合計ジャッジ時間 9,783 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
57,344 KB
testcase_01 AC 147 ms
57,712 KB
testcase_02 AC 147 ms
57,580 KB
testcase_03 AC 146 ms
57,656 KB
testcase_04 AC 144 ms
57,260 KB
testcase_05 AC 145 ms
57,868 KB
testcase_06 AC 151 ms
57,456 KB
testcase_07 AC 146 ms
57,952 KB
testcase_08 AC 148 ms
57,816 KB
testcase_09 AC 151 ms
57,588 KB
testcase_10 AC 146 ms
57,940 KB
testcase_11 AC 147 ms
57,948 KB
testcase_12 AC 149 ms
57,944 KB
testcase_13 AC 149 ms
57,896 KB
testcase_14 AC 150 ms
57,480 KB
testcase_15 AC 149 ms
57,808 KB
testcase_16 AC 147 ms
57,836 KB
testcase_17 AC 148 ms
57,944 KB
testcase_18 AC 147 ms
57,628 KB
testcase_19 AC 148 ms
57,988 KB
testcase_20 AC 148 ms
57,712 KB
testcase_21 AC 148 ms
57,900 KB
testcase_22 AC 148 ms
57,708 KB
testcase_23 AC 150 ms
57,660 KB
testcase_24 AC 151 ms
57,996 KB
testcase_25 AC 148 ms
57,648 KB
testcase_26 AC 150 ms
57,916 KB
testcase_27 AC 147 ms
57,772 KB
testcase_28 AC 149 ms
57,660 KB
testcase_29 AC 147 ms
57,596 KB
testcase_30 AC 150 ms
57,600 KB
testcase_31 AC 148 ms
57,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class No0345 {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		String s = in.next();
		int n = s.length();
		int min = 101;
		for (int i=0; i<n; i++) {
			if (s.charAt(i) != 'c') continue;
			int w = 0;
			for (int j=0; i+j<n; j++) {
				if (s.charAt(i+j) == 'w') w++;
				if (w == 2) {
					min = Math.min(min, j+1);
					break;
				}
			}
		}

		out.println(min == 101 ? "-1" : min);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		dump((end-start) + "ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}
0