結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
tenten
|
| 提出日時 | 2020-11-10 09:47:11 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 276 ms / 5,000 ms |
| コード長 | 519 bytes |
| コンパイル時間 | 2,453 ms |
| コンパイル使用メモリ | 74,424 KB |
| 実行使用メモリ | 48,300 KB |
| 最終ジャッジ日時 | 2024-07-22 17:15:32 |
| 合計ジャッジ時間 | 10,370 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int length = sc.nextInt();
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
Arrays.sort(arr);
int count = 0;
while (count < n && arr[count] <= length) {
length -= arr[count];
count++;
}
System.out.println(count);
}
}
tenten