結果

問題 No.345 最小チワワ問題
ユーザー t8m8⛄️t8m8⛄️
提出日時 2016-02-26 22:23:25
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 892 bytes
コンパイル時間 6,591 ms
コンパイル使用メモリ 81,680 KB
実行使用メモリ 58,072 KB
最終ジャッジ日時 2023-10-23 20:25:13
合計ジャッジ時間 9,013 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,592 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 125 ms
56,360 KB
testcase_08 AC 136 ms
57,632 KB
testcase_09 AC 136 ms
57,548 KB
testcase_10 AC 137 ms
57,344 KB
testcase_11 AC 125 ms
56,348 KB
testcase_12 AC 137 ms
57,636 KB
testcase_13 AC 129 ms
56,368 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 134 ms
57,620 KB
testcase_21 AC 134 ms
57,520 KB
testcase_22 AC 132 ms
55,580 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 133 ms
57,408 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 134 ms
57,660 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 w = 0;
		int x = -1;
		int max = -1;
		for (int i=n-1; i>=0; i--) {
			if (s.charAt(i) == 'w') {
				if (w == 0) x = i;
				w++;
			}

			if (w > 1 && s.charAt(i) == 'c') {
				max = x - i + 1;
			}
		}

		out.println(max);
	}

	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