結果

問題 No.5 数字のブロック
ユーザー dogwood0424dogwood0424
提出日時 2017-11-29 20:42:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 257 ms / 5,000 ms
コード長 437 bytes
コンパイル時間 3,634 ms
コンパイル使用メモリ 74,768 KB
実行使用メモリ 60,652 KB
最終ジャッジ日時 2023-08-11 17:56:10
合計ジャッジ時間 11,768 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,900 KB
testcase_01 AC 120 ms
55,732 KB
testcase_02 AC 122 ms
55,824 KB
testcase_03 AC 229 ms
59,488 KB
testcase_04 AC 213 ms
59,192 KB
testcase_05 AC 238 ms
59,804 KB
testcase_06 AC 213 ms
59,176 KB
testcase_07 AC 197 ms
59,308 KB
testcase_08 AC 227 ms
60,416 KB
testcase_09 AC 192 ms
58,152 KB
testcase_10 AC 236 ms
59,684 KB
testcase_11 AC 210 ms
59,636 KB
testcase_12 AC 230 ms
59,628 KB
testcase_13 AC 240 ms
60,348 KB
testcase_14 AC 132 ms
55,544 KB
testcase_15 AC 158 ms
56,132 KB
testcase_16 AC 236 ms
60,092 KB
testcase_17 AC 254 ms
60,300 KB
testcase_18 AC 250 ms
60,328 KB
testcase_19 AC 257 ms
60,652 KB
testcase_20 AC 129 ms
55,976 KB
testcase_21 AC 127 ms
56,044 KB
testcase_22 AC 122 ms
56,256 KB
testcase_23 AC 121 ms
55,712 KB
testcase_24 AC 147 ms
55,872 KB
testcase_25 AC 169 ms
56,296 KB
testcase_26 AC 125 ms
55,528 KB
testcase_27 AC 124 ms
55,516 KB
testcase_28 AC 125 ms
55,436 KB
testcase_29 AC 208 ms
59,120 KB
testcase_30 AC 200 ms
56,520 KB
testcase_31 AC 124 ms
55,800 KB
testcase_32 AC 127 ms
55,796 KB
testcase_33 AC 123 ms
55,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
public class No5 {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);

		int length = sc.nextInt();
		int n = sc.nextInt();
		int []w = new int[n];

		for(int i=0;i<n;i++) {
			w[i]=sc.nextInt();
		}
		Arrays.sort(w);

		int cnt=0;
		for(int j=0;j<n;j++) {
			length = length-w[j];

			if(length<0)	break;

			cnt++ ;

		}

		System.out.println(cnt);

	}

}
0