結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2017-02-19 16:22:58 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 299 ms / 5,000 ms |
| コード長 | 833 bytes |
| コンパイル時間 | 3,703 ms |
| コンパイル使用メモリ | 76,824 KB |
| 実行使用メモリ | 48,220 KB |
| 最終ジャッジ日時 | 2024-11-18 10:53:59 |
| 合計ジャッジ時間 | 11,644 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Box {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int l = scanner.nextInt();
int n = scanner.nextInt();
ArrayList<Integer> width = new ArrayList();
for(int i=0;i<n;i++){
width.add(scanner.nextInt());
}
Collections.sort(width);
int sum = 0;
int count = 0;
for(int i=0;i<width.size();i++){
sum += width.get(i);
if(sum <= l){
count++;
}else{
break;
}
}
System.out.println(count);
}
}