結果

問題 No.110 しましまピラミッド
ユーザー holegumaholeguma
提出日時 2015-08-21 23:04:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,547 bytes
コンパイル時間 2,521 ms
コンパイル使用メモリ 74,988 KB
実行使用メモリ 52,136 KB
最終ジャッジ日時 2023-09-25 15:09:41
合計ジャッジ時間 5,207 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,716 KB
testcase_01 AC 43 ms
49,520 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 44 ms
49,492 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 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 44 ms
49,468 KB
testcase_20 AC 45 ms
49,568 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 42 ms
49,512 KB
testcase_26 AC 43 ms
49,564 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]==w[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]==w[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