結果

問題 No.204 ゴールデン・ウィーク(2)
コンテスト
ユーザー spacia
提出日時 2016-01-19 00:05:20
言語 Java
(openjdk 27 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 36 ms / 1,000 ms
+ 193µs
コード長 933 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,488 ms
コンパイル使用メモリ 86,716 KB
実行使用メモリ 43,728 KB
最終ジャッジ日時 2026-10-07 06:41:05
合計ジャッジ時間 5,784 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.*;
import java.util.*;
import java.math.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static int solve (String s , int n) {
		int ret = 0;
		int len = s.length();
		for (int i = 0; i < len; i++) {
			int cnt = 0 , j = i;
			char[] c = s.toCharArray();
			while (j < len && cnt < n && c[j] == 'x') {
				cnt++;
				c[j++] = 'o';
			}
			//out(Arrays.toString(c));
			j = 0;
			cnt = 0;
			while (j < len) {
				while (j < len && c[j] == 'o') {
					cnt++;
					j++;
				}
				j++;
				ret = Math.max(ret , cnt);
				cnt = 0;
			}
		}
		return ret;
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String w1 = br.readLine();
		String w2 = br.readLine();
		String x = "xxxxxxxxxxxxxx";
		out(solve(x + w1 + w2 + x , n));
	}
	
}
0