結果

問題 No.345 最小チワワ問題
ユーザー t8m8⛄️t8m8⛄️
提出日時 2016-02-26 22:29:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 4,364 ms
コンパイル使用メモリ 81,344 KB
実行使用メモリ 57,960 KB
最終ジャッジ日時 2023-10-23 20:29:43
合計ジャッジ時間 9,398 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
57,788 KB
testcase_01 AC 135 ms
57,688 KB
testcase_02 AC 134 ms
57,224 KB
testcase_03 AC 136 ms
57,328 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 136 ms
57,792 KB
testcase_08 AC 137 ms
57,808 KB
testcase_09 AC 137 ms
57,640 KB
testcase_10 AC 137 ms
57,748 KB
testcase_11 AC 134 ms
57,552 KB
testcase_12 AC 140 ms
57,696 KB
testcase_13 AC 138 ms
57,744 KB
testcase_14 WA -
testcase_15 AC 137 ms
57,600 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 137 ms
57,764 KB
testcase_20 AC 135 ms
57,484 KB
testcase_21 AC 135 ms
57,324 KB
testcase_22 AC 151 ms
57,652 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 136 ms
57,492 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 136 ms
57,720 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, y = -1;
		int max = -1;
		for (int i=n-1; i>=0; i--) {
			if (s.charAt(i) == 'w') {
				if (w == 0) {
					y = i;
				} else if (w == 1) {
					x = i;
				} else {
					y = x;
					x = i;
				}
				w++;
			}

			if (w > 1 && s.charAt(i) == 'c') {
				max = y - 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