結果
| 問題 |
No.50 おもちゃ箱
|
| コンテスト | |
| ユーザー |
kou6839
|
| 提出日時 | 2014-12-19 15:54:08 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 953 bytes |
| コンパイル時間 | 4,467 ms |
| コンパイル使用メモリ | 77,532 KB |
| 実行使用メモリ | 41,912 KB |
| 最終ジャッジ日時 | 2024-06-12 01:47:01 |
| 合計ジャッジ時間 | 10,296 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 23 WA * 15 |
ソースコード
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);
}
}
kou6839