結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2019-06-12 15:37:04 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 295 ms / 5,000 ms |
| コード長 | 651 bytes |
| コンパイル時間 | 2,372 ms |
| コンパイル使用メモリ | 76,276 KB |
| 実行使用メモリ | 57,544 KB |
| 最終ジャッジ日時 | 2024-10-10 20:59:15 |
| 合計ジャッジ時間 | 10,091 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
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
} // cla