結果

問題 No.2298 yukicounter
ユーザー tentententen
提出日時 2023-05-29 10:33:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 2,065 bytes
コンパイル時間 3,085 ms
コンパイル使用メモリ 83,724 KB
実行使用メモリ 56,016 KB
最終ジャッジ日時 2023-08-27 23:37:28
合計ジャッジ時間 7,927 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,564 KB
testcase_01 AC 41 ms
49,240 KB
testcase_02 AC 41 ms
49,332 KB
testcase_03 AC 146 ms
53,180 KB
testcase_04 AC 101 ms
52,512 KB
testcase_05 AC 72 ms
51,800 KB
testcase_06 AC 173 ms
55,608 KB
testcase_07 AC 100 ms
52,256 KB
testcase_08 AC 78 ms
52,112 KB
testcase_09 AC 93 ms
52,228 KB
testcase_10 AC 51 ms
49,468 KB
testcase_11 AC 97 ms
52,696 KB
testcase_12 AC 86 ms
52,428 KB
testcase_13 AC 105 ms
52,572 KB
testcase_14 AC 105 ms
52,476 KB
testcase_15 AC 42 ms
49,396 KB
testcase_16 AC 81 ms
51,828 KB
testcase_17 AC 73 ms
51,636 KB
testcase_18 AC 41 ms
49,272 KB
testcase_19 AC 42 ms
49,948 KB
testcase_20 AC 40 ms
49,328 KB
testcase_21 AC 43 ms
49,356 KB
testcase_22 AC 111 ms
52,324 KB
testcase_23 AC 104 ms
52,692 KB
testcase_24 AC 184 ms
56,016 KB
testcase_25 AC 138 ms
54,956 KB
testcase_26 AC 98 ms
52,472 KB
testcase_27 AC 171 ms
55,524 KB
testcase_28 AC 86 ms
52,716 KB
testcase_29 AC 83 ms
52,116 KB
testcase_30 AC 50 ms
49,416 KB
testcase_31 AC 80 ms
52,172 KB
testcase_32 AC 94 ms
52,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        String s = sc.next();
        String yukicoder = "yukicoder";
        int yLength = yukicoder.length();
        ArrayList<Integer> ans = new ArrayList<>();
        int idx = 0;
        while ((idx = s.indexOf(yukicoder, idx)) != -1) {
            ans.add(idx);
            idx++;
        }
        int count = 0;
        int current = 0;
        int prev = -yLength - 1;
        for (int x : ans) {
            if (x - prev == yLength) {
                current++;
            } else {
                current = 1;
            }
            count = Math.max(count, current);
            prev = x;
        }
        System.out.println(count);
    }
}

class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0