結果
| 問題 |
No.204 ゴールデン・ウィーク(2)
|
| コンテスト | |
| ユーザー |
chiho_miyako
|
| 提出日時 | 2015-05-08 23:51:02 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,888 bytes |
| コンパイル時間 | 2,100 ms |
| コンパイル使用メモリ | 79,840 KB |
| 実行使用メモリ | 56,088 KB |
| 最終ジャッジ日時 | 2024-10-13 11:56:55 |
| 合計ジャッジ時間 | 9,276 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 26 |
ソースコード
import java.util.*;
class Ideone{
public static void main (String[] args) throws java.lang.Exception
{
Scanner koko = new Scanner(System.in);
int d = koko.nextInt();
String one = koko.next();
String two = koko.next();
String whole = one + two;
if(whole.equals("xxxxxxxxxxxxxx")){
System.out.println(d);
}else if(whole.equals("oooooooooooooo")){
System.out.println(14);
}else{
String[] on = whole.split("o+");
int[] onseq = new int[on.length];
int counton = 0;
int countoff = 0;
int onp =0;
int offp =0;
for(int i=0; i<on.length; i++){
if(on[i].length()!=0){
onseq[onp++]=on[i].length();
counton++;
}
}
String[] off = whole.split("x+");
int[] offseq = new int[off.length];
for(int i=0; i<off.length; i++){
if(off[i].length()!=0){
offseq[offp++]=off[i].length();
countoff++;
}
}
int max=0;
if(countoff>counton){
for(int i=0; i<counton; i++){
if(onseq[i]<=d){
max=Math.max(max, offseq[i]+onseq[i]+offseq[i+1]);
}else{
max=Math.max(max, offseq[i]+d);
max=Math.max(max, offseq[i+1]+d);
}
}
}else if(countoff==counton){
if(whole.charAt(0)=='o'){
if(countoff==1){
max=offseq[0]+Math.min(d, onseq[0]);
}else{
for(int i=0; i<counton-1; i++){
if(onseq[i]<=d){
max=Math.max(max, offseq[i]+onseq[i]+offseq[i+1]);
}else{
max=Math.max(max, offseq[i]+d);
max=Math.max(max, offseq[i+1]+d);
}
}
if(onseq[counton-1]<=d){
max=Math.max(max, offseq[counton-1]+onseq[counton-1]);
}else{
max=Math.max(max, offseq[counton-1]+d);
}
}
}else{
max=offseq[0]+Math.min(d, onseq[0]);
for(int i=1; i<counton-1; i++){
if(onseq[i]<=d){
max=Math.max(max, offseq[i-1]+onseq[i]+offseq[i]);
}else{
max=Math.max(max, offseq[i-1]+d);
max=Math.max(max, offseq[i]+d);
}
}
}
}else if(countoff<counton){
if(onseq[0]<=d){
max=onseq[0]+offseq[0];
}
if(countoff==1){
if(on[1].length()<=d){
max=Math.max(max, offseq[0]+onseq[1]);
}else{
max=Math.max(max, offseq[0]+d);
}
}else{
for(int i=1; i<counton-1; i++){
if(onseq[i]<=d){
max=Math.max(max, offseq[i-1]+onseq[i]+offseq[i]);
}else{
max=Math.max(max, offseq[i-1]+d);
max=Math.max(max, offseq[i]+d);
}
}
max=Math.max(max, offseq[countoff-1]+Math.min(d, onseq[counton-1]));
}
}
System.out.println(max);
}
}
}
chiho_miyako