結果
問題 |
No.110 しましまピラミッド
|
ユーザー |
![]() |
提出日時 | 2015-08-21 23:06:09 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,439 bytes |
コンパイル時間 | 2,331 ms |
コンパイル使用メモリ | 78,092 KB |
実行使用メモリ | 37,344 KB |
最終ジャッジ日時 | 2024-07-18 12:05:43 |
合計ジャッジ時間 | 4,515 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 24 WA * 2 |
ソースコード
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(); } }