結果

問題 No.110 しましまピラミッド
ユーザー holegumaholeguma
提出日時 2015-08-21 23:06:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,439 bytes
コンパイル時間 2,329 ms
コンパイル使用メモリ 75,136 KB
実行使用メモリ 51,612 KB
最終ジャッジ日時 2023-09-25 15:19:00
合計ジャッジ時間 5,063 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,684 KB
testcase_01 AC 46 ms
49,516 KB
testcase_02 AC 45 ms
49,404 KB
testcase_03 AC 45 ms
49,648 KB
testcase_04 AC 46 ms
49,448 KB
testcase_05 AC 46 ms
49,540 KB
testcase_06 AC 45 ms
49,696 KB
testcase_07 AC 45 ms
49,480 KB
testcase_08 AC 45 ms
49,476 KB
testcase_09 AC 45 ms
49,568 KB
testcase_10 AC 46 ms
49,692 KB
testcase_11 AC 45 ms
49,500 KB
testcase_12 AC 46 ms
49,996 KB
testcase_13 AC 45 ms
49,396 KB
testcase_14 AC 47 ms
49,548 KB
testcase_15 AC 46 ms
49,480 KB
testcase_16 AC 47 ms
49,460 KB
testcase_17 AC 45 ms
49,488 KB
testcase_18 AC 45 ms
49,636 KB
testcase_19 WA -
testcase_20 AC 46 ms
51,612 KB
testcase_21 AC 46 ms
49,492 KB
testcase_22 AC 46 ms
49,488 KB
testcase_23 WA -
testcase_24 AC 46 ms
49,520 KB
testcase_25 AC 46 ms
49,456 KB
testcase_26 AC 46 ms
47,936 KB
testcase_27 AC 46 ms
49,708 KB
testcase_28 AC 46 ms
49,360 KB
testcase_29 AC 46 ms
49,848 KB
権限があれば一括ダウンロードができます

ソースコード

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) break;
prev=b[insertionIndex-1];
ans1++;
res=Arrays.binarySearch(w,prev);
insertionIndex=(res>=0)?res:~res;
if(insertionIndex==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) break;
prev=w[insertionIndex-1];
ans2++;
res=Arrays.binarySearch(b,prev);
insertionIndex=(res>=0)?res:~res;
if(insertionIndex==0) break;
prev=b[insertionIndex-1];
ans2++;
}
out.println(Math.max(ans1,ans2));
}
out.flush();
}
}
0