結果

問題 No.5 数字のブロック
ユーザー Naoyk1212Naoyk1212
提出日時 2015-07-24 15:18:13
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 414 bytes
コンパイル時間 1,947 ms
コンパイル使用メモリ 71,912 KB
実行使用メモリ 60,928 KB
最終ジャッジ日時 2023-09-22 22:13:08
合計ジャッジ時間 9,440 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,480 KB
testcase_01 AC 124 ms
53,792 KB
testcase_02 RE -
testcase_03 AC 228 ms
59,760 KB
testcase_04 AC 211 ms
59,196 KB
testcase_05 AC 237 ms
59,808 KB
testcase_06 AC 219 ms
59,512 KB
testcase_07 AC 210 ms
59,256 KB
testcase_08 AC 224 ms
60,348 KB
testcase_09 AC 192 ms
57,988 KB
testcase_10 AC 240 ms
59,836 KB
testcase_11 AC 213 ms
59,848 KB
testcase_12 AC 232 ms
59,388 KB
testcase_13 AC 245 ms
60,084 KB
testcase_14 AC 136 ms
56,004 KB
testcase_15 AC 156 ms
56,192 KB
testcase_16 AC 244 ms
59,936 KB
testcase_17 AC 253 ms
60,492 KB
testcase_18 AC 250 ms
60,244 KB
testcase_19 AC 258 ms
60,928 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 123 ms
55,808 KB
testcase_24 AC 152 ms
56,152 KB
testcase_25 AC 180 ms
56,612 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 206 ms
59,288 KB
testcase_30 AC 199 ms
58,752 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int l = sc.nextInt();
		int n = sc.nextInt();
		int[] N = new int[n];
		int ans = 0;

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

		int i = 0;
		while(l >= ans){
			ans += N[i];
			i++;
		}
		System.out.println(i - 1);
	}

}
0