結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 37zigen37zigen
提出日時 2020-03-19 01:06:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 2,699 ms
コンパイル使用メモリ 82,156 KB
実行使用メモリ 42,804 KB
最終ジャッジ日時 2024-05-08 02:58:23
合計ジャッジ時間 12,860 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
42,540 KB
testcase_01 AC 169 ms
42,416 KB
testcase_02 AC 166 ms
42,348 KB
testcase_03 WA -
testcase_04 AC 167 ms
42,432 KB
testcase_05 AC 165 ms
42,312 KB
testcase_06 AC 168 ms
42,144 KB
testcase_07 AC 168 ms
42,372 KB
testcase_08 AC 172 ms
42,152 KB
testcase_09 AC 167 ms
42,300 KB
testcase_10 AC 168 ms
42,036 KB
testcase_11 AC 165 ms
42,600 KB
testcase_12 WA -
testcase_13 AC 165 ms
42,452 KB
testcase_14 AC 166 ms
42,344 KB
testcase_15 AC 161 ms
42,320 KB
testcase_16 AC 172 ms
42,532 KB
testcase_17 AC 168 ms
42,372 KB
testcase_18 AC 167 ms
42,576 KB
testcase_19 AC 168 ms
42,452 KB
testcase_20 AC 170 ms
42,432 KB
testcase_21 AC 170 ms
42,408 KB
testcase_22 AC 169 ms
42,312 KB
testcase_23 AC 169 ms
42,448 KB
testcase_24 AC 169 ms
42,408 KB
testcase_25 AC 169 ms
42,096 KB
testcase_26 AC 169 ms
42,376 KB
testcase_27 AC 169 ms
42,264 KB
testcase_28 AC 164 ms
42,628 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 169 ms
42,136 KB
testcase_32 AC 167 ms
42,688 KB
testcase_33 AC 171 ms
42,252 KB
testcase_34 AC 170 ms
42,300 KB
testcase_35 AC 174 ms
42,352 KB
testcase_36 AC 177 ms
42,268 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 161 ms
42,296 KB
testcase_40 WA -
testcase_41 AC 168 ms
42,536 KB
testcase_42 AC 164 ms
42,216 KB
testcase_43 WA -
testcase_44 AC 162 ms
42,608 KB
testcase_45 AC 148 ms
41,952 KB
testcase_46 WA -
testcase_47 AC 165 ms
42,116 KB
testcase_48 AC 174 ms
42,520 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