結果

問題 No.5 数字のブロック
ユーザー kou6839kou6839
提出日時 2014-11-08 16:29:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 275 ms / 5,000 ms
コード長 568 bytes
コンパイル時間 2,254 ms
コンパイル使用メモリ 74,776 KB
実行使用メモリ 47,624 KB
最終ジャッジ日時 2024-04-29 00:22:59
合計ジャッジ時間 9,831 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
41,296 KB
testcase_01 AC 134 ms
41,348 KB
testcase_02 AC 134 ms
41,140 KB
testcase_03 AC 244 ms
46,232 KB
testcase_04 AC 228 ms
45,432 KB
testcase_05 AC 256 ms
47,072 KB
testcase_06 AC 232 ms
46,204 KB
testcase_07 AC 222 ms
45,632 KB
testcase_08 AC 242 ms
46,472 KB
testcase_09 AC 202 ms
43,440 KB
testcase_10 AC 261 ms
47,240 KB
testcase_11 AC 233 ms
46,596 KB
testcase_12 AC 251 ms
46,504 KB
testcase_13 AC 254 ms
47,260 KB
testcase_14 AC 145 ms
41,460 KB
testcase_15 AC 155 ms
41,424 KB
testcase_16 AC 252 ms
46,128 KB
testcase_17 AC 268 ms
47,604 KB
testcase_18 AC 269 ms
46,580 KB
testcase_19 AC 275 ms
47,624 KB
testcase_20 AC 134 ms
41,016 KB
testcase_21 AC 133 ms
41,228 KB
testcase_22 AC 131 ms
40,956 KB
testcase_23 AC 134 ms
41,404 KB
testcase_24 AC 160 ms
41,588 KB
testcase_25 AC 185 ms
41,860 KB
testcase_26 AC 132 ms
41,480 KB
testcase_27 AC 133 ms
41,144 KB
testcase_28 AC 136 ms
41,332 KB
testcase_29 AC 228 ms
45,660 KB
testcase_30 AC 208 ms
43,384 KB
testcase_31 AC 133 ms
41,276 KB
testcase_32 AC 133 ms
41,148 KB
testcase_33 AC 131 ms
41,440 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