結果

問題 No.5 数字のブロック
ユーザー DemocoDemoco
提出日時 2015-05-01 18:09:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 434 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 71,664 KB
実行使用メモリ 61,128 KB
最終ジャッジ日時 2023-09-19 04:55:00
合計ジャッジ時間 10,262 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 132 ms
56,024 KB
testcase_02 AC 129 ms
56,052 KB
testcase_03 AC 244 ms
60,228 KB
testcase_04 AC 219 ms
59,496 KB
testcase_05 AC 254 ms
60,184 KB
testcase_06 AC 232 ms
60,320 KB
testcase_07 AC 218 ms
59,156 KB
testcase_08 AC 230 ms
59,500 KB
testcase_09 AC 199 ms
58,136 KB
testcase_10 AC 248 ms
59,616 KB
testcase_11 AC 224 ms
59,844 KB
testcase_12 AC 245 ms
60,012 KB
testcase_13 AC 259 ms
60,068 KB
testcase_14 AC 140 ms
55,776 KB
testcase_15 AC 162 ms
55,540 KB
testcase_16 AC 248 ms
60,376 KB
testcase_17 AC 258 ms
60,732 KB
testcase_18 AC 257 ms
60,648 KB
testcase_19 AC 272 ms
61,128 KB
testcase_20 AC 129 ms
55,752 KB
testcase_21 AC 129 ms
56,028 KB
testcase_22 AC 127 ms
55,560 KB
testcase_23 AC 126 ms
55,508 KB
testcase_24 AC 153 ms
55,716 KB
testcase_25 AC 186 ms
56,200 KB
testcase_26 AC 130 ms
54,108 KB
testcase_27 AC 128 ms
55,788 KB
testcase_28 AC 125 ms
55,756 KB
testcase_29 AC 226 ms
59,152 KB
testcase_30 AC 203 ms
60,340 KB
testcase_31 AC 129 ms
55,552 KB
testcase_32 AC 126 ms
55,908 KB
testcase_33 AC 127 ms
55,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class Yukico5 {
	public static void main(String[] args){
		Scanner stdin = new Scanner(System.in);
		int l = stdin.nextInt();
		int n = stdin.nextInt();
		int[] w = new int[n];
		for(int i=0; i<n; i++) {
			w[i] = stdin.nextInt();
		}
		Arrays.sort(w);
		
		int a=0;
		int i=0;
		while(a<=l && i<n) {
			a = a+w[i];
			i++;
		}
		if(i==n) {
			System.out.println(i);
		} else {
			System.out.println(i-1);
		}
	}
}
0