結果

問題 No.5 数字のブロック
ユーザー soujikisoujiki
提出日時 2015-04-24 18:04:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 254 ms / 5,000 ms
コード長 427 bytes
コンパイル時間 3,412 ms
コンパイル使用メモリ 72,124 KB
実行使用メモリ 60,584 KB
最終ジャッジ日時 2023-08-11 08:17:49
合計ジャッジ時間 11,020 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,976 KB
testcase_01 AC 124 ms
55,780 KB
testcase_02 AC 122 ms
55,940 KB
testcase_03 AC 226 ms
59,068 KB
testcase_04 AC 213 ms
58,992 KB
testcase_05 AC 242 ms
59,724 KB
testcase_06 AC 219 ms
59,216 KB
testcase_07 AC 210 ms
59,380 KB
testcase_08 AC 217 ms
60,076 KB
testcase_09 AC 200 ms
58,568 KB
testcase_10 AC 247 ms
60,320 KB
testcase_11 AC 216 ms
59,420 KB
testcase_12 AC 240 ms
60,380 KB
testcase_13 AC 245 ms
60,000 KB
testcase_14 AC 131 ms
55,964 KB
testcase_15 AC 149 ms
56,244 KB
testcase_16 AC 243 ms
59,920 KB
testcase_17 AC 254 ms
60,452 KB
testcase_18 AC 250 ms
60,456 KB
testcase_19 AC 254 ms
60,584 KB
testcase_20 AC 125 ms
55,516 KB
testcase_21 AC 124 ms
55,804 KB
testcase_22 AC 126 ms
55,720 KB
testcase_23 AC 126 ms
56,384 KB
testcase_24 AC 150 ms
55,716 KB
testcase_25 AC 179 ms
55,920 KB
testcase_26 AC 123 ms
55,448 KB
testcase_27 AC 125 ms
55,396 KB
testcase_28 AC 121 ms
55,800 KB
testcase_29 AC 212 ms
58,776 KB
testcase_30 AC 194 ms
58,500 KB
testcase_31 AC 122 ms
55,716 KB
testcase_32 AC 124 ms
55,716 KB
testcase_33 AC 124 ms
55,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Yukicoder_5{
	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 count = 0;

		for(int i=0;i<N;i++){
			if(L-W[i]<0){
				break;
			}
			L = L - W[i];
			count++;
		}

		System.out.println(count);

	}
}
0