結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2016-11-12 19:07:20 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 661 bytes |
| 記録 | |
| コンパイル時間 | 1,510 ms |
| コンパイル使用メモリ | 81,756 KB |
| 実行使用メモリ | 41,688 KB |
| 最終ジャッジ日時 | 2026-04-12 16:41:53 |
| 合計ジャッジ時間 | 4,385 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String S = sc.next();
int a = S.indexOf("c");
int min = Integer.MAX_VALUE;
while(a!=-1){
S = S.substring(a+1);
int b = S.indexOf("w");
String t = S.substring(b+1);
int c = t.indexOf("w");
if(c!=-1 && min>b+c+3){
min = b+c+3;
}
a = S.indexOf("c");
}
if(min==Integer.MAX_VALUE){
System.out.println(-1);
}else{
System.out.println(min);
}
}
}
kohaku_kohaku