結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2016-03-11 01:46:44 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 141 ms / 2,000 ms |
コード長 | 481 bytes |
コンパイル時間 | 4,485 ms |
コンパイル使用メモリ | 73,880 KB |
実行使用メモリ | 41,612 KB |
最終ジャッジ日時 | 2024-09-25 11:39:09 |
合計ジャッジ時間 | 7,223 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); String str=sc.next(); int ans=Integer.MAX_VALUE; for(int i=0;i<str.length();i++){ for(int j=i+1;j<str.length();j++){ for(int k=j+1;k<str.length();k++){ if(str.charAt(i)=='c'&&str.charAt(j)=='w'&&str.charAt(k)=='w'){ ans=Math.min(ans,k-i+1); } } } } if(ans==Integer.MAX_VALUE) ans=-1; System.out.println(ans); } }