結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2016-12-09 16:14:13 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 701 bytes |
コンパイル時間 | 2,413 ms |
コンパイル使用メモリ | 75,684 KB |
実行使用メモリ | 60,000 KB |
最終ジャッジ日時 | 2024-11-28 16:20:55 |
合計ジャッジ時間 | 10,889 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 RE * 10 |
ソースコード
import java.io.*; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main (String[] args) throws IOException { Scanner sc = new Scanner(System.in); int L = sc.nextInt(); int N = sc.nextInt(); int W[] = new int [N]; for (int i = 0 ; i <= N-1 ; i++){ W[i] = sc.nextInt(); } Arrays.sort(W); int sum = 0; int ans = 0; for (int j = 0; sum + W[j] <= L ; j++){ ans = ans + 1; sum = sum + W[j]; } System.out.println(ans); } }