結果

問題 No.110 しましまピラミッド
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-25 21:24:15
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 954 bytes
コンパイル時間 3,120 ms
コンパイル使用メモリ 77,968 KB
実行使用メモリ 55,128 KB
最終ジャッジ日時 2024-04-20 04:26:45
合計ジャッジ時間 7,592 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
54,096 KB
testcase_01 AC 112 ms
54,224 KB
testcase_02 AC 108 ms
54,076 KB
testcase_03 AC 97 ms
52,768 KB
testcase_04 AC 101 ms
52,956 KB
testcase_05 AC 113 ms
53,964 KB
testcase_06 AC 105 ms
52,880 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 112 ms
54,076 KB
testcase_14 WA -
testcase_15 AC 102 ms
53,140 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 114 ms
53,932 KB
testcase_19 WA -
testcase_20 AC 113 ms
54,164 KB
testcase_21 AC 106 ms
53,352 KB
testcase_22 WA -
testcase_23 AC 115 ms
54,220 KB
testcase_24 AC 102 ms
53,148 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 114 ms
54,120 KB
testcase_28 AC 113 ms
53,112 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
          }
        }
      }
    }
    return count;
  }
}
0