結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-02-26 23:02:51 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 587 bytes |
コンパイル時間 | 1,996 ms |
コンパイル使用メモリ | 77,852 KB |
実行使用メモリ | 55,980 KB |
最終ジャッジ日時 | 2024-09-22 22:39:33 |
合計ジャッジ時間 | 6,913 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 14 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); String str = sc.next(); char c1 = 'c'; char c2 = 'w'; int count = 0; int ans = -1; int i = 0; while(i < str.length()){ if(str.charAt(i) == c1){ int a = i; while(i < str.length()){ if(str.charAt(i) == c2){ count++; if(count == 2){ ans = i + 1 - a; break; } } i++; } break; } i++; } System.out.println(ans); } }