結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 37zigen37zigen
提出日時 2020-03-19 01:06:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 78,784 KB
実行使用メモリ 58,884 KB
最終ジャッジ日時 2023-08-20 20:32:30
合計ジャッジ時間 11,655 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
56,796 KB
testcase_01 AC 154 ms
56,556 KB
testcase_02 AC 154 ms
56,956 KB
testcase_03 WA -
testcase_04 AC 154 ms
56,672 KB
testcase_05 AC 154 ms
57,108 KB
testcase_06 AC 155 ms
56,436 KB
testcase_07 AC 153 ms
56,600 KB
testcase_08 AC 156 ms
56,864 KB
testcase_09 AC 154 ms
56,888 KB
testcase_10 AC 154 ms
57,124 KB
testcase_11 AC 157 ms
56,656 KB
testcase_12 WA -
testcase_13 AC 155 ms
56,832 KB
testcase_14 AC 154 ms
57,216 KB
testcase_15 AC 155 ms
56,512 KB
testcase_16 AC 157 ms
56,776 KB
testcase_17 AC 158 ms
56,612 KB
testcase_18 AC 157 ms
56,860 KB
testcase_19 AC 156 ms
56,896 KB
testcase_20 AC 157 ms
58,780 KB
testcase_21 AC 157 ms
56,852 KB
testcase_22 AC 159 ms
56,864 KB
testcase_23 AC 157 ms
56,676 KB
testcase_24 AC 157 ms
56,632 KB
testcase_25 AC 157 ms
56,876 KB
testcase_26 AC 155 ms
56,844 KB
testcase_27 AC 157 ms
56,620 KB
testcase_28 AC 159 ms
56,536 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 158 ms
56,436 KB
testcase_32 AC 156 ms
56,564 KB
testcase_33 AC 157 ms
56,688 KB
testcase_34 AC 158 ms
56,852 KB
testcase_35 AC 156 ms
56,772 KB
testcase_36 AC 155 ms
56,556 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 158 ms
56,932 KB
testcase_40 WA -
testcase_41 AC 156 ms
56,516 KB
testcase_42 AC 155 ms
56,800 KB
testcase_43 WA -
testcase_44 AC 156 ms
56,956 KB
testcase_45 AC 157 ms
58,684 KB
testcase_46 WA -
testcase_47 AC 158 ms
56,568 KB
testcase_48 AC 155 ms
56,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int D=sc.nextInt();
		char[] cs=("xxxxxxxxxxxxxx"+sc.next()+sc.next()+"xxxxxxxxxxxxxx").toCharArray();
		int[] a=new int[cs.length];
		int p=0;
		for(int i=0;i<cs.length;++i) {
			int j=i;
			while(j+1<cs.length&&cs[i]==cs[j+1])++j;
			a[p++]=j-i+1;
			i=j;
		}
		int cur=cs[0]=='x'?0:1;//x:平日
		int ans=0;
		for(int i=0;i<p;++i) {
			if(i%2==cur) {
				ans=Math.max(ans, (a[i]>=D&&i>0?a[i-1]:0)+Math.min(a[i],D)+(i+1<a.length?a[i+1]:0));
			}else {
				ans=Math.max(ans, a[i]+(i+1<a.length?(Math.min(a[i+1],D)+(i+2<a.length?a[i+2]:0)):0));
			}
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0