結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2016-11-12 19:07:20 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 120 ms / 2,000 ms |
| コード長 | 661 bytes |
| コンパイル時間 | 1,862 ms |
| コンパイル使用メモリ | 74,264 KB |
| 実行使用メモリ | 54,156 KB |
| 最終ジャッジ日時 | 2024-09-25 11:55:33 |
| 合計ジャッジ時間 | 6,394 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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