結果

問題 No.5 数字のブロック
ユーザー papipenpapipen
提出日時 2017-03-26 14:04:51
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 398 bytes
コンパイル時間 1,954 ms
コンパイル使用メモリ 71,644 KB
実行使用メモリ 61,996 KB
最終ジャッジ日時 2023-09-20 10:59:46
合計ジャッジ時間 9,549 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,880 KB
testcase_01 AC 121 ms
56,156 KB
testcase_02 RE -
testcase_03 AC 223 ms
59,560 KB
testcase_04 AC 210 ms
59,568 KB
testcase_05 AC 239 ms
60,840 KB
testcase_06 AC 210 ms
59,148 KB
testcase_07 AC 217 ms
59,564 KB
testcase_08 AC 228 ms
59,404 KB
testcase_09 AC 191 ms
58,764 KB
testcase_10 AC 242 ms
60,148 KB
testcase_11 AC 212 ms
59,572 KB
testcase_12 AC 232 ms
61,996 KB
testcase_13 AC 245 ms
60,212 KB
testcase_14 AC 135 ms
56,048 KB
testcase_15 AC 146 ms
56,256 KB
testcase_16 AC 240 ms
60,112 KB
testcase_17 AC 249 ms
60,160 KB
testcase_18 AC 250 ms
60,376 KB
testcase_19 AC 252 ms
61,104 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 121 ms
55,796 KB
testcase_24 AC 147 ms
55,736 KB
testcase_25 AC 174 ms
56,344 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 208 ms
59,460 KB
testcase_30 AC 196 ms
58,892 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

class Block{
	public static void main(String args[]){
		Scanner s = new Scanner(System.in);
		int L = s.nextInt();
		int N = s.nextInt();
		int W[] = new int[N];
		for(int i = 0; i < N; i++){
			W[i] = s.nextInt();
		}
		Arrays.sort(W);
		
		int sum = 0;
		int j = 0;
		while(sum <= L){
			sum += W[j];
			j++;
		}
		System.out.println(j-1);
	}
}
0