結果

問題 No.345 最小チワワ問題
ユーザー fal_rndfal_rnd
提出日時 2017-07-14 17:48:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 75,320 KB
実行使用メモリ 57,624 KB
最終ジャッジ日時 2023-10-26 04:12:56
合計ジャッジ時間 7,719 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,520 KB
testcase_01 AC 131 ms
57,268 KB
testcase_02 AC 128 ms
57,240 KB
testcase_03 AC 133 ms
57,524 KB
testcase_04 AC 129 ms
57,484 KB
testcase_05 AC 129 ms
57,256 KB
testcase_06 AC 130 ms
57,292 KB
testcase_07 AC 127 ms
57,300 KB
testcase_08 AC 130 ms
57,308 KB
testcase_09 AC 130 ms
57,300 KB
testcase_10 AC 136 ms
57,264 KB
testcase_11 AC 131 ms
57,284 KB
testcase_12 AC 130 ms
57,272 KB
testcase_13 AC 133 ms
57,600 KB
testcase_14 AC 133 ms
55,388 KB
testcase_15 AC 134 ms
57,228 KB
testcase_16 AC 134 ms
57,056 KB
testcase_17 AC 137 ms
57,220 KB
testcase_18 AC 135 ms
57,280 KB
testcase_19 AC 136 ms
57,220 KB
testcase_20 AC 137 ms
57,312 KB
testcase_21 AC 137 ms
57,276 KB
testcase_22 AC 139 ms
57,272 KB
testcase_23 AC 141 ms
57,252 KB
testcase_24 AC 135 ms
57,296 KB
testcase_25 AC 136 ms
57,296 KB
testcase_26 AC 134 ms
57,280 KB
testcase_27 AC 132 ms
57,624 KB
testcase_28 AC 136 ms
57,240 KB
testcase_29 AC 134 ms
57,292 KB
testcase_30 AC 134 ms
57,228 KB
testcase_31 AC 135 ms
57,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;

class C{
	public static void main(String[]$){
		char[]s=new java.util.Scanner(System.in).next().toCharArray();
		int r=114;
		List<Integer>d=new ArrayList<>();
		for(int i=s.length-1;i>=0;--i) {
			if(s[i]=='w')
				d.add(i);
			if(d.size()>2)
				d.remove(0);
			if(s[i]=='c'&&d.size()==2)
				r=Math.min(r,d.get(0)-i+1);
		}
		System.out.println(r==114?-1:r);
	}
}
0