結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2015-05-17 18:25:36 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 982 bytes |
コンパイル時間 | 2,106 ms |
コンパイル使用メモリ | 79,044 KB |
実行使用メモリ | 56,416 KB |
最終ジャッジ日時 | 2024-10-13 12:48:14 |
合計ジャッジ時間 | 10,246 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 25 WA * 21 |
ソースコード
import java.util.*; class Yukico204 { public static void main(String[] args) { Scanner stdio = new Scanner(System.in); int d = stdio.nextInt(); String s = stdio.next(); s += stdio.next(); s = "xxxxxxxxxxxxxx"+s+"xxxxxxxxxxxxxx"; int ans = d; int cnt=0; for(int i=0; i<s.length(); i++) { if(s.charAt(i) == 'o') { cnt++; ans = Math.max(ans, cnt); } else { cnt = 0; } } if(d==0) { System.out.println(ans); } else { cnt = 0; for(int i=0; i<s.length(); i++) { cnt = 0; boolean b=true; for(int j=i; j<s.length(); j++) { if((j-i)>=0 && (j-i)<d && b) { if(s.charAt(j) == 'o') { cnt++; ans = Math.max(ans, cnt); b = false; } else { cnt++; ans = Math.max(ans, cnt); } } else if(s.charAt(j) == 'o') { cnt++; ans = Math.max(ans, cnt); } else { cnt = 0; } } ans = Math.max(ans, cnt); } System.out.println(ans); } } }