結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー YamaKasaYamaKasa
提出日時 2018-08-11 20:01:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,773 bytes
コンパイル時間 4,555 ms
コンパイル使用メモリ 82,768 KB
実行使用メモリ 57,964 KB
最終ジャッジ日時 2023-10-24 14:00:06
合計ジャッジ時間 11,013 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 120 ms
57,384 KB
testcase_05 AC 117 ms
56,368 KB
testcase_06 AC 124 ms
57,444 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 123 ms
57,428 KB
testcase_12 AC 123 ms
57,380 KB
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 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 124 ms
57,448 KB
testcase_31 AC 123 ms
57,524 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 124 ms
57,496 KB
testcase_35 AC 128 ms
57,312 KB
testcase_36 AC 122 ms
57,476 KB
testcase_37 AC 123 ms
57,272 KB
testcase_38 AC 123 ms
57,532 KB
testcase_39 WA -
testcase_40 AC 123 ms
57,356 KB
testcase_41 AC 129 ms
57,376 KB
testcase_42 WA -
testcase_43 AC 123 ms
57,548 KB
testcase_44 AC 121 ms
57,408 KB
testcase_45 AC 124 ms
57,492 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int []a;
	static int ans = 0;
	static List<Integer> list;
	static char[]c;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int D = scan.nextInt();
		String C1 = scan.next();
		String C2 = scan.next();
		scan.close();
		c = new char[14];
		int cnt = 0;
		list = new ArrayList<Integer>();
		for(int i = 0; i < 7; i++) {
			char c1 = C1.charAt(i);
			char c2 = C2.charAt(i);
			c[i] = c1;
			c[i + 7] = c2;
			if(c1 == 'x') {
				cnt++;
				list.add(i);
			}
			if(c2 == 'x') {
				cnt++;
				list.add(i + 1);
			}
		}
		Collections.sort(list);
		if(cnt <= D) {
			System.out.println("14");
			System.exit(0);
		}
		a = new int[cnt];
		comb(1, D);
		System.out.println(ans);
	}
	static void comb(int m, int r) {
        int n = a.length;
        if(n == r) {
            return;
        }else if(n < r){
            System.out.println("エラー");
            System.exit(0);
        }
        if(m <= r) {
            int k = a[m - 1] + 1;
            for(int i = k; i <= n - r + m; i++){
                a[m] = i;
                comb(m + 1, r);
            }
        } else {
        	char[]b = new char[14];
        	for(int i = 0; i < 14; i++) {
        		b[i] = c[i];
        	}
        	for(int i = 1; i <= r; i++) {
        		//System.out.println(a[i]);
        		b[a[i] - 1] = 'o';
        	}
        	int t = solve(b);
        	if(ans < t) {
        		ans = t;
        	}
        }
    }
	static int solve(char []c) {
		int k = 0;
		int max = 0;
		for(int i = 0; i < 14; i++) {
			if(c[i] == 'o') {
				k++;
			}else {
				k = 0;
			}
			if(max < k) {
				max = k;
			}
		}
		return max;
	}
}
0