結果
| 問題 |
No.204 ゴールデン・ウィーク(2)
|
| コンテスト | |
| ユーザー |
chiho_miyako
|
| 提出日時 | 2015-05-09 00:09:43 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,648 bytes |
| コンパイル時間 | 2,235 ms |
| コンパイル使用メモリ | 79,396 KB |
| 実行使用メモリ | 55,064 KB |
| 最終ジャッジ日時 | 2024-10-13 11:58:38 |
| 合計ジャッジ時間 | 10,980 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 WA * 4 |
ソースコード
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 = "xxxxxxxxxxxxxx" + one + two + "xxxxxxxxxxxxxx";
if(whole.equals("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")){
System.out.println(d);
}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(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