結果

問題 No.345 最小チワワ問題
ユーザー t8m8⛄️
提出日時 2016-02-26 22:29:42
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 3,809 ms
コンパイル使用メモリ 81,540 KB
実行使用メモリ 56,256 KB
最終ジャッジ日時 2024-09-22 14:08:30
合計ジャッジ時間 9,385 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

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