結果

問題 No.110 しましまピラミッド
ユーザー kou6839kou6839
提出日時 2014-12-28 15:31:42
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,010 bytes
コンパイル時間 2,294 ms
コンパイル使用メモリ 75,652 KB
実行使用メモリ 56,240 KB
最終ジャッジ日時 2023-09-03 18:44:32
合計ジャッジ時間 6,408 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
56,072 KB
testcase_01 AC 109 ms
55,944 KB
testcase_02 AC 114 ms
55,564 KB
testcase_03 AC 112 ms
55,888 KB
testcase_04 AC 111 ms
55,912 KB
testcase_05 AC 109 ms
55,720 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 112 ms
55,936 KB
testcase_14 AC 112 ms
55,712 KB
testcase_15 AC 112 ms
55,480 KB
testcase_16 AC 108 ms
55,660 KB
testcase_17 AC 116 ms
55,700 KB
testcase_18 AC 112 ms
56,000 KB
testcase_19 AC 108 ms
56,076 KB
testcase_20 AC 108 ms
55,856 KB
testcase_21 AC 110 ms
55,952 KB
testcase_22 AC 114 ms
55,660 KB
testcase_23 AC 111 ms
56,080 KB
testcase_24 AC 114 ms
56,240 KB
testcase_25 AC 114 ms
55,896 KB
testcase_26 AC 115 ms
56,076 KB
testcase_27 AC 111 ms
55,916 KB
testcase_28 AC 114 ms
55,992 KB
testcase_29 AC 115 ms
55,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PriorityQueue<Integer> siro = new PriorityQueue<>();
        PriorityQueue<Integer> kuro = new PriorityQueue<>();
        int nw = sc.nextInt();
        for(int i=0;i<nw;i++){
        	int aaaa=sc.nextInt();
        	siro.offer(-aaaa);
        }
        PriorityQueue<Integer> siro1 = new PriorityQueue<>(siro);
        int nb=sc.nextInt();
        for (int i = 0; i <nb; i++) {
        	int aaaa=sc.nextInt();
        	kuro.offer(-aaaa);
		}

        PriorityQueue<Integer> kuro1 = new PriorityQueue<>(kuro);
        int ans=1;
        int count1=1;
    	int now=-1*siro.poll();
        while(!kuro.isEmpty() || !siro.isEmpty()){
        	int bb=0;
        	while(!kuro.isEmpty()){
        		bb=-1*kuro.poll();
        		if(bb<now) break;
        	}
	        if(now>bb){ 
	        	now=bb;
	        	count1++;
	        }else{
	        	break;
	        }
	        int aa=0;
	        if(siro.isEmpty())break;
	        while(!siro.isEmpty()){
	        	aa=-1*siro.poll();
	        	if(now>aa)break;
	        }
	        if(now>aa){
	        	now=aa;
	        	count1++;
	        }else{
	        	break;
	        }
	     }
        ans=count1;
        int count2=1;
        int now1=-1*kuro1.poll();
        while(!kuro1.isEmpty() || !siro1.isEmpty()){
        	int bb=0;
        	if(siro1.isEmpty())break;
        	while(!siro1.isEmpty()){
        		bb=-1*siro1.poll();
        		if(bb<now1) break;
        	}
	        if(now1>bb){ 
	        	now1=bb;
	        	count2++;
	        }else{
	        	break;
	        }
	        int aa=0;
	        if(kuro1.isEmpty()) break;
	        while(!kuro1.isEmpty()){
	        	aa=-1*kuro1.poll();
	        	if(aa<now1) break;
	        }
	        if(now1>aa){
	        	now1=aa;
	        	count2++;
	        }else{
	        	break;
	        }
	     }
        	ans=Math.max(ans, count2);
        	System.out.println(ans);
    }
}
0