結果

問題 No.5 数字のブロック
ユーザー kou6839kou6839
提出日時 2014-11-08 16:13:15
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 431 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 73,712 KB
実行使用メモリ 60,776 KB
最終ジャッジ日時 2023-08-30 02:42:07
合計ジャッジ時間 9,944 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,272 KB
testcase_01 AC 124 ms
55,828 KB
testcase_02 RE -
testcase_03 AC 228 ms
59,224 KB
testcase_04 AC 214 ms
58,976 KB
testcase_05 AC 243 ms
59,956 KB
testcase_06 AC 221 ms
59,340 KB
testcase_07 AC 214 ms
59,224 KB
testcase_08 AC 231 ms
59,644 KB
testcase_09 AC 199 ms
58,764 KB
testcase_10 AC 240 ms
59,776 KB
testcase_11 AC 213 ms
59,660 KB
testcase_12 AC 239 ms
57,788 KB
testcase_13 AC 252 ms
60,428 KB
testcase_14 AC 137 ms
56,268 KB
testcase_15 AC 154 ms
56,396 KB
testcase_16 AC 247 ms
60,108 KB
testcase_17 AC 254 ms
60,776 KB
testcase_18 AC 253 ms
60,672 KB
testcase_19 AC 259 ms
60,448 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 126 ms
56,068 KB
testcase_24 AC 152 ms
56,328 KB
testcase_25 AC 175 ms
56,476 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 214 ms
59,328 KB
testcase_30 AC 195 ms
58,484 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 

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