結果

問題 No.50 おもちゃ箱
ユーザー kou6839kou6839
提出日時 2014-12-19 15:54:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 953 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 74,080 KB
実行使用メモリ 56,832 KB
最終ジャッジ日時 2023-09-02 19:22:20
合計ジャッジ時間 10,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 123 ms
55,560 KB
testcase_04 WA -
testcase_05 AC 124 ms
54,376 KB
testcase_06 AC 124 ms
55,824 KB
testcase_07 AC 124 ms
56,256 KB
testcase_08 AC 123 ms
56,424 KB
testcase_09 AC 124 ms
55,628 KB
testcase_10 AC 126 ms
55,872 KB
testcase_11 AC 125 ms
56,076 KB
testcase_12 AC 124 ms
55,844 KB
testcase_13 AC 123 ms
55,772 KB
testcase_14 AC 124 ms
56,008 KB
testcase_15 AC 125 ms
55,828 KB
testcase_16 AC 127 ms
56,104 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 122 ms
56,004 KB
testcase_20 AC 123 ms
56,168 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 125 ms
55,972 KB
testcase_27 AC 125 ms
55,616 KB
testcase_28 AC 127 ms
56,232 KB
testcase_29 WA -
testcase_30 AC 126 ms
56,160 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 127 ms
55,744 KB
testcase_34 AC 124 ms
56,704 KB
testcase_35 WA -
testcase_36 AC 123 ms
55,760 KB
testcase_37 AC 124 ms
56,172 KB
testcase_38 WA -
testcase_39 AC 124 ms
56,340 KB
testcase_40 AC 126 ms
56,624 KB
testcase_41 AC 126 ms
55,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n= sc.nextInt();
        int[] omo = new int[n];
        for(int i=0;i<n;i++){
        	omo[i]=sc.nextInt();
        }
        Arrays.sort(omo);
        int m = sc.nextInt();
        int[] hako =new int[m];
        boolean[] use = new boolean[m];
        for(int i=0;i<m;i++){
        	hako[i]=sc.nextInt();
        }
        Arrays.sort(hako);
        for(int i=n-1;i>=0;i--){
        	for(int j=m-1;j>=0;j--){
        		if(omo[i]<=hako[j]){
        			hako[j]-=omo[i];
        			use[j]=true;
        			break;
        		}else{
        			if(j==-1){
        				System.out.println(-1);
        			}
        			continue;
        		}
        	}
        }
        int ans=0;
        for(int i=0;i<m;i++){
        	if(use[i])ans++;
        }
        System.out.println(ans);
        
    }
}
0