結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー kenji_shioya
提出日時 2016-06-23 00:45:46
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 835 bytes
コンパイル時間 4,083 ms
コンパイル使用メモリ 76,804 KB
実行使用メモリ 41,624 KB
最終ジャッジ日時 2024-10-13 14:03:09
合計ジャッジ時間 10,154 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise112{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int d = sc.nextInt();
    String weeks = sc.next() + sc.next();
    char[] wa = weeks.toCharArray();
    int max = 0;
    int xCount = 0;
    for(int i = 0; i < wa.length; i++){
      if(wa[i] == 'x'){
        xCount++;
        if(xCount >= d){
          char[] wd = Arrays.copyOf(wa, wa.length);
          for(int j = 0; j < d; j++){
            wd[i - j] = 'o';
          }
          int oCount = 0;
          for(char charInWd: wd){
            if(charInWd == 'o'){
              oCount++;
              max = Math.max(max, oCount);
            }else{
              oCount = 0;
            }
          }
        }
      }else{
        xCount = 0;
      }
    }
    System.out.println(max);
  }
}
0