結果
| 問題 | 
                            No.204 ゴールデン・ウィーク(2)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kuramu
                         | 
                    
| 提出日時 | 2016-01-30 13:40:44 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,358 bytes | 
| コンパイル時間 | 2,352 ms | 
| コンパイル使用メモリ | 77,376 KB | 
| 実行使用メモリ | 51,936 KB | 
| 最終ジャッジ日時 | 2024-10-13 13:52:33 | 
| 合計ジャッジ時間 | 5,870 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 WA * 25 | 
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) {
	      BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));
	      boolean[] N = new boolean[14];
	      try {
	    	  int D = Integer.parseInt(stdReader.readLine());
	    	  String[] temp1 = stdReader.readLine().split("");
	    	  String[] temp2 = stdReader.readLine().split("");
	    	 
	    	  int ans = 0;
	    	  for(int i=0;i<7;i++)
	    		  if(temp1[i].equals("o")) N[i] = true;
	    	  for(int i=7;i<14;i++)
	    		  if(temp2[i-7].equals("o")) N[i] = true;
	    	  
	    	  for(int i=0;i<14;i++){
	    		  int count = 0;
	    		  for(int j=0;j<D && i+j <14 ;j++){
	    			  if(!N[i+j]){
	    				  count++;
	    				  N[i+j] = true;
	    			  }else{
	    				  break;
	    			  }
	    		  }	    		  
	    		  ans = Math.max(ans, calc(N));
	    		  for(int j=0;j<count;j++){
	    			  N[i+j] = false;
	    		  }
	    	  }
	    	  System.out.println(ans);
	      } catch (IOException e) {
			e.printStackTrace();
	      }
	}
	
	public static int calc(boolean[] N){
		int count = 0;
		int ans = 0;
		for(int i=0;i<N.length;i++){
			if(N[i]){
				count++;	
			}else{
				ans = Math.max(ans, count);
				count=0;
			}
		}	
		ans = Math.max(ans, count);
		return ans;
	}
}
            
            
            
        
            
kuramu