結果
問題 | No.5 数字のブロック |
ユーザー | m4s4k1ch1 |
提出日時 | 2015-05-28 00:39:32 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 93 ms / 5,000 ms |
コード長 | 712 bytes |
コンパイル時間 | 1,823 ms |
コンパイル使用メモリ | 74,496 KB |
実行使用メモリ | 40,316 KB |
最終ジャッジ日時 | 2024-11-17 22:47:47 |
合計ジャッジ時間 | 4,906 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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); } }