結果

問題 No.5 数字のブロック
ユーザー len_proglen_prog
提出日時 2016-06-08 09:34:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 270 ms / 5,000 ms
コード長 520 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 74,340 KB
実行使用メモリ 47,472 KB
最終ジャッジ日時 2024-04-29 07:21:06
合計ジャッジ時間 9,690 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,104 KB
testcase_01 AC 132 ms
41,232 KB
testcase_02 AC 130 ms
41,236 KB
testcase_03 AC 248 ms
46,224 KB
testcase_04 AC 227 ms
45,636 KB
testcase_05 AC 260 ms
46,412 KB
testcase_06 AC 241 ms
46,196 KB
testcase_07 AC 237 ms
45,604 KB
testcase_08 AC 248 ms
46,340 KB
testcase_09 AC 197 ms
43,496 KB
testcase_10 AC 249 ms
46,496 KB
testcase_11 AC 214 ms
46,092 KB
testcase_12 AC 249 ms
46,664 KB
testcase_13 AC 265 ms
46,176 KB
testcase_14 AC 142 ms
41,432 KB
testcase_15 AC 163 ms
41,404 KB
testcase_16 AC 266 ms
46,220 KB
testcase_17 AC 265 ms
47,472 KB
testcase_18 AC 267 ms
46,196 KB
testcase_19 AC 270 ms
47,468 KB
testcase_20 AC 131 ms
41,052 KB
testcase_21 AC 129 ms
41,060 KB
testcase_22 AC 121 ms
39,872 KB
testcase_23 AC 137 ms
40,968 KB
testcase_24 AC 154 ms
41,456 KB
testcase_25 AC 182 ms
41,840 KB
testcase_26 AC 128 ms
41,356 KB
testcase_27 AC 133 ms
41,080 KB
testcase_28 AC 133 ms
41,024 KB
testcase_29 AC 225 ms
45,648 KB
testcase_30 AC 208 ms
43,576 KB
testcase_31 AC 130 ms
41,384 KB
testcase_32 AC 132 ms
41,320 KB
testcase_33 AC 117 ms
40,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int L = scan.nextInt();
		int N = scan.nextInt();
		int[] numbers = new int[N];

		for(int i = 0; i < numbers.length; i++){
			numbers[i] = scan.nextInt();
		}

		Arrays.sort(numbers);
		int total = 0;
		int count = 0;

		for(int i = 0; i < numbers.length; i++){
			total += numbers[i];
			if(total > L) break;

			count++;
		}
		System.out.println(count);
	}

}
0