結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
|
提出日時 | 2020-03-15 18:34:28 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 175 ms / 1,000 ms |
コード長 | 853 bytes |
コンパイル時間 | 5,212 ms |
コンパイル使用メモリ | 79,216 KB |
実行使用メモリ | 55,084 KB |
最終ジャッジ日時 | 2024-11-25 07:10:18 |
合計ジャッジ時間 | 13,359 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;if(c.charAt(i) == 'x') {while(h < d && j < c.length()) {if(c.charAt(j) == 'x') {cc += "o";h++;j++;}else {break;}}}else {continue;}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);}}