結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
h_tyokinuhata
|
| 提出日時 | 2015-12-19 23:31:30 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 241 ms / 5,000 ms |
| コード長 | 523 bytes |
| コンパイル時間 | 2,124 ms |
| コンパイル使用メモリ | 76,476 KB |
| 実行使用メモリ | 59,036 KB |
| 最終ジャッジ日時 | 2024-11-18 08:00:44 |
| 合計ジャッジ時間 | 8,451 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Integer> W = new ArrayList<>();
int L = sc.nextInt();
int N = sc.nextInt();
for(int i = 0; i < N; i++) {
W.add(sc.nextInt());
}
Collections.sort(W);
int i = 0;
while(L >= 0 && i < N) {
L = L - W.get(i);
if(L >= 0) {
i++;
} else {
break;
}
}
System.out.println(i);
}
}
h_tyokinuhata