結果

問題 No.5 数字のブロック
ユーザー shinwisteriashinwisteria
提出日時 2017-03-18 20:02:35
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 407 bytes
コンパイル時間 4,256 ms
コンパイル使用メモリ 72,548 KB
実行使用メモリ 60,692 KB
最終ジャッジ日時 2023-09-18 02:34:55
合計ジャッジ時間 10,628 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,960 KB
testcase_01 AC 126 ms
55,652 KB
testcase_02 RE -
testcase_03 AC 231 ms
59,856 KB
testcase_04 AC 213 ms
59,244 KB
testcase_05 AC 241 ms
59,948 KB
testcase_06 AC 223 ms
59,724 KB
testcase_07 AC 214 ms
58,956 KB
testcase_08 AC 231 ms
59,988 KB
testcase_09 AC 197 ms
59,176 KB
testcase_10 AC 242 ms
60,652 KB
testcase_11 AC 215 ms
59,200 KB
testcase_12 AC 236 ms
59,868 KB
testcase_13 AC 241 ms
60,204 KB
testcase_14 AC 137 ms
55,812 KB
testcase_15 AC 155 ms
55,968 KB
testcase_16 AC 242 ms
60,692 KB
testcase_17 AC 253 ms
60,504 KB
testcase_18 AC 248 ms
60,380 KB
testcase_19 AC 253 ms
60,312 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 123 ms
55,856 KB
testcase_24 AC 149 ms
56,068 KB
testcase_25 AC 168 ms
56,028 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 213 ms
59,048 KB
testcase_30 AC 194 ms
58,412 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class NumberBlock {

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

}
0