結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2015-05-08 23:00:09 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 816 bytes |
コンパイル時間 | 3,934 ms |
コンパイル使用メモリ | 78,944 KB |
実行使用メモリ | 42,328 KB |
最終ジャッジ日時 | 2024-10-13 11:41:41 |
合計ジャッジ時間 | 11,932 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 33 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int D = sc.nextInt(); String string = sc.next() + sc.next(); string = string.replaceAll("o", "1").replaceAll("x", "0"); int max = 0; for (int i = 0; i < (1 << 14); i++) { if (Integer.bitCount(i & Integer.parseInt(string, 2)) != Integer.bitCount(Integer.parseInt(string, 2))) { continue; } if (Integer.bitCount(i) > Integer.bitCount(Integer.parseInt(string, 2)) + D) { continue; } char[] bits = ("0" + Integer.toBinaryString(i) + "0").toCharArray(); int cnt = 0; for (int j = 0; j < bits.length; j++) { if (bits[j] == '1') { cnt++; } else { max = Math.max(max, cnt); cnt = 0; } } } System.out.println(max); } }