結果

問題 No.110 しましまピラミッド
コンテスト
ユーザー kohaku_kohaku
提出日時 2016-12-03 06:25:48
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 65 ms / 5,000 ms
コード長 948 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,682 ms
コンパイル使用メモリ 83,004 KB
実行使用メモリ 42,300 KB
最終ジャッジ日時 2026-06-04 23:12:58
合計ジャッジ時間 4,737 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int Nw = sc.nextInt();
        int [] W = new int [Nw];
        for(int i=0; i<Nw; i++){
            W[i] = sc.nextInt();
        }
        Arrays.sort(W);
        int Nb = sc.nextInt();
        int [] B = new int [Nb];
        for(int i=0; i<Nb; i++){
            B[i] = sc.nextInt();
        }
        Arrays.sort(B);
        int rw=arrange(W,B,W[0]);
        int rb=arrange(B,W,B[0]);
        int ans=Math.max(rw,rb);
        System.out.println(ans);
    }
    static int arrange(int []a, int []b, int c){
        if(c>=b[b.length-1]){
            return 1;
        }else{
            for(int i=0; i<b.length; i++){
                if(c<b[i]){
                    c=b[i];
                    break;
                }
            }
            int x=1+arrange(b,a,c);
            return x;
        }
    }
}
0