結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-28 00:39:32 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 5,000 ms |
| コード長 | 712 bytes |
| 記録 | |
| コンパイル時間 | 2,375 ms |
| コンパイル使用メモリ | 82,608 KB |
| 実行使用メモリ | 41,320 KB |
| 最終ジャッジ日時 | 2026-05-12 16:16:58 |
| 合計ジャッジ時間 | 4,675 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int l = Integer.parseInt(line);
line = br.readLine();
int n = Integer.parseInt(line);
line = br.readLine();
String[] lines = line.split(" ");
int[] ws = new int[n];
for (int t = 0; t < n; t++) {
ws[t] = Integer.parseInt(lines[t]);
}
Arrays.sort(ws);
int total = 0;
int res = 0;
for (int w : ws) {
if ((total + w) > l) {
break;
}
total += w;
res++;
}
System.out.println(res);
}
}