結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-06-12 15:33:21 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 652 bytes |
| コンパイル時間 | 2,242 ms |
| コンパイル使用メモリ | 75,836 KB |
| 実行使用メモリ | 47,756 KB |
| 最終ジャッジ日時 | 2024-10-10 20:50:22 |
| 合計ジャッジ時間 | 10,224 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 7 |
ソースコード
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int box = sc.nextInt();
int count = sc.nextInt();
ArrayList<Integer> boxlist = new ArrayList<Integer>();
for(int i=0;i<count;i++){
int input = sc.nextInt();
boxlist.add(input);
}
sc.close();
Collections.sort(boxlist);
int total=0;
int result = 0;
for(int k=0;box>total&&boxlist.size()>k;k++){
total += boxlist.get(k);
if(box>total){
result++;
}else{
break;
}
}
System.out.println(result);
}// mainmethod
} // class