結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 37zigen37zigen
提出日時 2020-03-19 01:03:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 2,289 ms
コンパイル使用メモリ 76,972 KB
実行使用メモリ 57,852 KB
最終ジャッジ日時 2023-08-20 20:32:17
合計ジャッジ時間 10,273 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,308 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 126 ms
55,468 KB
testcase_05 AC 125 ms
55,844 KB
testcase_06 AC 125 ms
55,612 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 126 ms
55,612 KB
testcase_26 AC 127 ms
55,492 KB
testcase_27 AC 124 ms
55,428 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 126 ms
55,784 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 126 ms
55,660 KB
testcase_35 AC 126 ms
55,696 KB
testcase_36 AC 127 ms
56,252 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 124 ms
55,744 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 127 ms
55,612 KB
testcase_45 AC 124 ms
53,664 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 125 ms
55,860 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=(sc.next()+sc.next()).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