結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
|
提出日時 | 2020-03-15 18:36:25 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 157 ms / 1,000 ms |
コード長 | 786 bytes |
コンパイル時間 | 3,058 ms |
コンパイル使用メモリ | 79,112 KB |
実行使用メモリ | 55,296 KB |
最終ジャッジ日時 | 2024-11-25 07:11:56 |
合計ジャッジ時間 | 11,378 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
import java.util.*; import java.io.*; import java.math.*; public class No204 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int d = sc.nextInt(); String c = "xxxxxxxxxxxxxx" + sc.next() + sc.next() + "xxxxxxxxxxxxxx"; int ans = 0; int t = 0; for(int i = 0; i < c.length(); i++) { String cc = c.substring(0, i); int h = 0, j = i; while(h < d && j < c.length()) { if(c.charAt(j) == 'x') { cc += "o"; h++; j++; }else { break; } } cc += c.substring(j, c.length()); int tmp = 0; for(int k = 0; k < c.length(); k++) { if(cc.charAt(k) == 'o') { tmp++; }else { ans = Math.max(ans, tmp); tmp = 0; } } ans = Math.max(ans, tmp); } System.out.println(ans); } }