結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー DemocoDemoco
提出日時 2015-05-17 18:36:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 1,000 ms
コード長 981 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 76,360 KB
実行使用メモリ 57,160 KB
最終ジャッジ日時 2023-08-25 23:42:35
合計ジャッジ時間 10,051 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
56,584 KB
testcase_01 AC 136 ms
56,944 KB
testcase_02 AC 132 ms
56,752 KB
testcase_03 AC 133 ms
56,988 KB
testcase_04 AC 129 ms
56,560 KB
testcase_05 AC 129 ms
56,732 KB
testcase_06 AC 132 ms
56,748 KB
testcase_07 AC 129 ms
56,764 KB
testcase_08 AC 134 ms
56,672 KB
testcase_09 AC 132 ms
56,800 KB
testcase_10 AC 127 ms
56,984 KB
testcase_11 AC 129 ms
56,724 KB
testcase_12 AC 127 ms
56,896 KB
testcase_13 AC 131 ms
57,120 KB
testcase_14 AC 130 ms
56,856 KB
testcase_15 AC 125 ms
56,912 KB
testcase_16 AC 127 ms
56,964 KB
testcase_17 AC 127 ms
57,092 KB
testcase_18 AC 128 ms
57,084 KB
testcase_19 AC 130 ms
56,792 KB
testcase_20 AC 129 ms
56,620 KB
testcase_21 AC 129 ms
56,972 KB
testcase_22 AC 133 ms
56,780 KB
testcase_23 AC 135 ms
56,532 KB
testcase_24 AC 131 ms
56,900 KB
testcase_25 AC 132 ms
56,696 KB
testcase_26 AC 137 ms
56,648 KB
testcase_27 AC 135 ms
56,944 KB
testcase_28 AC 127 ms
56,584 KB
testcase_29 AC 129 ms
56,756 KB
testcase_30 AC 127 ms
56,616 KB
testcase_31 AC 134 ms
56,900 KB
testcase_32 AC 124 ms
56,832 KB
testcase_33 AC 125 ms
57,060 KB
testcase_34 AC 127 ms
56,880 KB
testcase_35 AC 125 ms
56,588 KB
testcase_36 AC 124 ms
56,864 KB
testcase_37 AC 126 ms
57,160 KB
testcase_38 AC 124 ms
56,544 KB
testcase_39 AC 123 ms
56,884 KB
testcase_40 AC 124 ms
56,836 KB
testcase_41 AC 127 ms
56,628 KB
testcase_42 AC 142 ms
56,696 KB
testcase_43 AC 123 ms
56,896 KB
testcase_44 AC 124 ms
56,856 KB
testcase_45 AC 126 ms
56,532 KB
testcase_46 AC 122 ms
56,588 KB
testcase_47 AC 126 ms
54,856 KB
testcase_48 AC 127 ms
56,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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=0; 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);
		}
	}
}
0