結果

問題 No.110 しましまピラミッド
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-25 21:29:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 973 bytes
コンパイル時間 3,601 ms
コンパイル使用メモリ 74,720 KB
実行使用メモリ 57,764 KB
最終ジャッジ日時 2023-08-30 03:56:02
合計ジャッジ時間 8,408 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,948 KB
testcase_01 AC 125 ms
55,756 KB
testcase_02 AC 125 ms
55,948 KB
testcase_03 AC 127 ms
55,588 KB
testcase_04 AC 125 ms
56,096 KB
testcase_05 AC 128 ms
56,316 KB
testcase_06 AC 126 ms
55,808 KB
testcase_07 AC 124 ms
55,760 KB
testcase_08 AC 127 ms
55,860 KB
testcase_09 AC 127 ms
55,920 KB
testcase_10 AC 126 ms
55,984 KB
testcase_11 AC 126 ms
56,200 KB
testcase_12 AC 129 ms
55,948 KB
testcase_13 AC 125 ms
56,264 KB
testcase_14 AC 129 ms
55,876 KB
testcase_15 AC 127 ms
55,868 KB
testcase_16 AC 126 ms
55,856 KB
testcase_17 AC 131 ms
56,112 KB
testcase_18 AC 127 ms
55,840 KB
testcase_19 AC 126 ms
56,048 KB
testcase_20 AC 126 ms
56,132 KB
testcase_21 AC 124 ms
55,848 KB
testcase_22 AC 126 ms
55,840 KB
testcase_23 AC 125 ms
56,052 KB
testcase_24 AC 124 ms
55,960 KB
testcase_25 AC 126 ms
56,220 KB
testcase_26 AC 124 ms
57,764 KB
testcase_27 AC 125 ms
55,844 KB
testcase_28 AC 123 ms
56,248 KB
testcase_29 AC 125 ms
55,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise127{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] w = new int[n];
    for(int i = 0; i < n; i++){
      w[i] = sc.nextInt();
    }
    Arrays.sort(w);
    n = sc.nextInt();
    int[] b = new int[n];
    for(int i = 0; i < n; i++){
      b[i] = sc.nextInt();
    }
    Arrays.sort(b);
    System.out.println(Math.max(build(w, b), build(b, w)));
	}
  private static int build(int[] first, int[] second){
    int top = first[first.length - 1];
    int count = 1;
    boolean f = true;
    for(int i = second.length - 1; i >= 0; i--){
      if(second[i] < top && f){
        top = second[i];
        count++;
        f = false;
        for(int j = first.length - 1; j >=0; j--){
          if(first[j] < top){
            top = first[j];
            count++;
            f = true;
            break;
          }
        }
      }
    }
    return count;
  }
}
0