結果

問題 No.5 数字のブロック
ユーザー kou6839kou6839
提出日時 2014-11-08 16:29:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 253 ms / 5,000 ms
コード長 568 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 71,204 KB
実行使用メモリ 60,604 KB
最終ジャッジ日時 2023-08-11 07:46:19
合計ジャッジ時間 9,318 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,724 KB
testcase_01 AC 120 ms
56,188 KB
testcase_02 AC 120 ms
55,644 KB
testcase_03 AC 224 ms
59,700 KB
testcase_04 AC 208 ms
59,452 KB
testcase_05 AC 236 ms
60,300 KB
testcase_06 AC 211 ms
60,096 KB
testcase_07 AC 208 ms
59,272 KB
testcase_08 AC 213 ms
59,612 KB
testcase_09 AC 201 ms
58,716 KB
testcase_10 AC 236 ms
60,252 KB
testcase_11 AC 215 ms
59,628 KB
testcase_12 AC 232 ms
59,612 KB
testcase_13 AC 245 ms
60,324 KB
testcase_14 AC 135 ms
55,916 KB
testcase_15 AC 148 ms
55,872 KB
testcase_16 AC 235 ms
59,960 KB
testcase_17 AC 253 ms
60,604 KB
testcase_18 AC 248 ms
60,396 KB
testcase_19 AC 247 ms
60,172 KB
testcase_20 AC 122 ms
56,376 KB
testcase_21 AC 125 ms
56,044 KB
testcase_22 AC 121 ms
56,432 KB
testcase_23 AC 120 ms
55,836 KB
testcase_24 AC 142 ms
56,412 KB
testcase_25 AC 175 ms
56,092 KB
testcase_26 AC 122 ms
55,860 KB
testcase_27 AC 122 ms
54,004 KB
testcase_28 AC 121 ms
55,820 KB
testcase_29 AC 207 ms
59,620 KB
testcase_30 AC 192 ms
58,736 KB
testcase_31 AC 120 ms
56,072 KB
testcase_32 AC 121 ms
55,908 KB
testcase_33 AC 118 ms
56,184 KB
権限があれば一括ダウンロードができます

ソースコード

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++;
			if(iti==N){
				if(sum>L){
					System.out.println(ans-1);
					return;
				}
				System.out.println(ans);
				return;
			}
		}
		System.out.println(ans-1);
	}
}	
0