結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
t8m8⛄️
|
| 提出日時 | 2016-02-26 22:32:42 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 152 ms / 2,000 ms |
| コード長 | 941 bytes |
| コンパイル時間 | 3,736 ms |
| コンパイル使用メモリ | 83,824 KB |
| 実行使用メモリ | 42,088 KB |
| 最終ジャッジ日時 | 2024-09-25 11:24:14 |
| 合計ジャッジ時間 | 9,326 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;
public class No0345 {
static final Scanner in = new Scanner(System.in);
static final PrintWriter out = new PrintWriter(System.out,false);
static boolean debug = false;
static void solve() {
String s = in.next();
int n = s.length();
int min = 101;
for (int i=0; i<n; i++) {
if (s.charAt(i) != 'c') continue;
int w = 0;
for (int j=0; i+j<n; j++) {
if (s.charAt(i+j) == 'w') w++;
if (w == 2) {
min = Math.min(min, j+1);
break;
}
}
}
out.println(min == 101 ? "-1" : min);
}
public static void main(String[] args) {
debug = args.length > 0;
long start = System.currentTimeMillis();
solve();
out.flush();
long end = System.currentTimeMillis();
dump((end-start) + "ms");
in.close();
out.close();
}
static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}
t8m8⛄️