結果

問題 No.5 数字のブロック
ユーザー doyazaki012doyazaki012
提出日時 2015-04-24 17:47:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 255 ms / 5,000 ms
コード長 442 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 71,796 KB
実行使用メモリ 62,144 KB
最終ジャッジ日時 2023-08-11 08:17:34
合計ジャッジ時間 9,602 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,916 KB
testcase_01 AC 125 ms
55,820 KB
testcase_02 AC 123 ms
55,856 KB
testcase_03 AC 232 ms
59,468 KB
testcase_04 AC 209 ms
58,564 KB
testcase_05 AC 239 ms
62,144 KB
testcase_06 AC 208 ms
59,660 KB
testcase_07 AC 214 ms
59,544 KB
testcase_08 AC 226 ms
59,480 KB
testcase_09 AC 195 ms
58,740 KB
testcase_10 AC 240 ms
60,316 KB
testcase_11 AC 216 ms
59,544 KB
testcase_12 AC 233 ms
60,756 KB
testcase_13 AC 244 ms
60,096 KB
testcase_14 AC 137 ms
55,788 KB
testcase_15 AC 161 ms
56,180 KB
testcase_16 AC 240 ms
59,768 KB
testcase_17 AC 254 ms
60,372 KB
testcase_18 AC 251 ms
60,648 KB
testcase_19 AC 255 ms
60,424 KB
testcase_20 AC 121 ms
55,972 KB
testcase_21 AC 120 ms
56,040 KB
testcase_22 AC 120 ms
55,788 KB
testcase_23 AC 123 ms
55,812 KB
testcase_24 AC 158 ms
55,776 KB
testcase_25 AC 181 ms
56,156 KB
testcase_26 AC 123 ms
55,972 KB
testcase_27 AC 122 ms
55,788 KB
testcase_28 AC 125 ms
55,772 KB
testcase_29 AC 212 ms
59,404 KB
testcase_30 AC 195 ms
58,356 KB
testcase_31 AC 122 ms
55,820 KB
testcase_32 AC 121 ms
55,700 KB
testcase_33 AC 124 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

	
		int l = stdIn.nextInt();
		int n = stdIn.nextInt();
		int[] w = new int[n]; 
		for(int i=0;i<n;i++){
			w[i] = stdIn.nextInt();
		}
		Arrays.sort(w);
		int k=0;
		int sum = 0;
		while(sum<=l){
			sum+=w[k];
			k++;
			if(k==n&&sum<=l){
				k++;
				break;
			}else if(k==n)
				break;
		}
		System.out.println(k-1);
	}
}
0