結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
![]() |
提出日時 | 2015-05-09 14:56:50 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 140 ms / 1,000 ms |
コード長 | 1,067 bytes |
コンパイル時間 | 2,398 ms |
コンパイル使用メモリ | 87,672 KB |
実行使用メモリ | 41,800 KB |
最終ジャッジ日時 | 2024-12-24 11:44:17 |
合計ジャッジ時間 | 9,886 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
import java.io.File; import java.util.*; public class Main { static int cul(String a){ int ans=0; for(int i=0;i<a.length();i++){ if(a.charAt(i)=='o'){ int temp=1; int j=1; while(i+j<a.length() && a.charAt(i+j)=='o'){ j++; temp++; } ans=Math.max(ans, temp); i+=j; } } return ans; } public static void main(String[] args){ // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String a = sc.next(); String b = sc.next(); a+=b; int ans=0; String aa ="xxxxxxxxxxxxxxxxxxxxxxxx"; aa+=a; aa+="xxxxxxxxxxxxxxxxxxxx"; for(int k=0;k<=n;k++){ String rep =""; for(int w=0;w<k;w++) rep+="o"; //System.out.println(rep); int i=0; tt:while(i+k-1<aa.length()){ for(int j=i;j<i+k;j++){ if(aa.charAt(j)=='o'){ i++; continue tt; } } StringBuilder c = new StringBuilder(aa); c.replace(i, i+k,rep); //System.out.println(c); ans=Math.max(ans, cul(c.toString())); i++; } } System.out.println(ans); } }