結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-21 01:43:23 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 147 ms / 5,000 ms |
| コード長 | 1,192 bytes |
| コンパイル時間 | 4,074 ms |
| コンパイル使用メモリ | 77,472 KB |
| 実行使用メモリ | 56,212 KB |
| 最終ジャッジ日時 | 2024-12-31 11:42:44 |
| 合計ジャッジ時間 | 9,575 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
import java.util.Scanner;
import java.util.Arrays;
public class No110{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N_w = sc.nextInt();
int[] W = new int[N_w];
for(int i = 0; i < N_w; i++){
W[i] = sc.nextInt();
}
int N_b = sc.nextInt();
int[] B = new int[N_b];
for(int i = 0; i < N_b; i++){
B[i] = sc.nextInt();
}
Arrays.sort(W);
Arrays.sort(B);
int height_w_start = stack(W, B);
int height_b_start = stack(B, W);
System.out.println(Math.max(height_w_start, height_b_start));
}
private static int stack(int[] block_0, int[] block_1){
int height = 0;
int width = 30;
int max;
boolean put_flg;
while(true){
max = 0;
put_flg = false;
for(int i = 0; i < block_0.length; i++){
if(block_0[i] > max && block_0[i] < width){
max = block_0[i];
put_flg = true;
}
}
if(put_flg) height++;
else break;
width = max;
max = 0;
put_flg = false;
for(int i = 0; i < block_1.length; i++){
if(block_1[i] > max && block_1[i] < width){
max = block_1[i];
put_flg = true;
}
}
if(put_flg) height++;
else break;
width = max;
}
return height;
}
}