結果

問題 No.110 しましまピラミッド
ユーザー holegumaholeguma
提出日時 2015-08-21 23:03:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,547 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 74,724 KB
実行使用メモリ 50,180 KB
最終ジャッジ日時 2023-09-25 15:17:44
合計ジャッジ時間 4,996 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,492 KB
testcase_01 AC 46 ms
47,616 KB
testcase_02 WA -
testcase_03 AC 46 ms
49,568 KB
testcase_04 AC 44 ms
49,428 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 45 ms
49,468 KB
testcase_14 WA -
testcase_15 AC 46 ms
49,688 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 46 ms
49,408 KB
testcase_20 AC 46 ms
49,496 KB
testcase_21 WA -
testcase_22 AC 44 ms
49,424 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 45 ms
49,640 KB
testcase_26 AC 45 ms
49,696 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{

static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(in));
StringTokenizer st;
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int nw=Integer.parseInt(line);
st=new StringTokenizer(br.readLine());
int res,insertionIndex;
int[] w=new int[nw];
for(int i=0;i<nw;i++) w[i]=Integer.parseInt(st.nextToken());
int nb=Integer.parseInt(br.readLine());
st=new StringTokenizer(br.readLine());
int[] b=new int[nb];
for(int i=0;i<nb;i++) b[i]=Integer.parseInt(st.nextToken());
Arrays.sort(w);
Arrays.sort(b);
int ans1,ans2;
ans1=ans2=1;
int prev=w[nw-1];
while(true){
res=Arrays.binarySearch(b,prev);
insertionIndex=(res>=0)?res:~res;
if(insertionIndex==0||b[insertionIndex-1]==b[0]) break;
prev=b[insertionIndex-1];
ans1++;
res=Arrays.binarySearch(w,prev);
insertionIndex=(res>=0)?res:~res;
if(insertionIndex==0||w[insertionIndex-1]==b[0]) break;
prev=w[insertionIndex-1];
ans1++;
}
prev=b[nb-1];
while(true){
res=Arrays.binarySearch(w,prev);
insertionIndex=(res>=0)?res:~res;
if(insertionIndex==0||w[insertionIndex-1]==b[0]) break;
prev=w[insertionIndex-1];
ans2++;
res=Arrays.binarySearch(b,prev);
insertionIndex=(res>=0)?res:~res;
if(insertionIndex==0||b[insertionIndex-1]==b[0]) break;
prev=b[insertionIndex-1];
ans2++;
}
out.println(Math.max(ans1,ans2));
}
out.flush();
}
}
0