結果

問題 No.5 数字のブロック
ユーザー soujikisoujiki
提出日時 2015-04-24 18:04:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 286 ms / 5,000 ms
コード長 427 bytes
コンパイル時間 3,512 ms
コンパイル使用メモリ 75,280 KB
実行使用メモリ 58,752 KB
最終ジャッジ日時 2024-04-29 00:52:09
合計ジャッジ時間 11,570 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
53,952 KB
testcase_01 AC 136 ms
54,236 KB
testcase_02 AC 135 ms
54,052 KB
testcase_03 AC 251 ms
58,208 KB
testcase_04 AC 233 ms
57,168 KB
testcase_05 AC 269 ms
57,956 KB
testcase_06 AC 244 ms
57,724 KB
testcase_07 AC 236 ms
57,588 KB
testcase_08 AC 263 ms
58,260 KB
testcase_09 AC 225 ms
57,096 KB
testcase_10 AC 279 ms
58,752 KB
testcase_11 AC 238 ms
57,468 KB
testcase_12 AC 252 ms
58,076 KB
testcase_13 AC 260 ms
57,964 KB
testcase_14 AC 152 ms
54,260 KB
testcase_15 AC 169 ms
53,896 KB
testcase_16 AC 265 ms
57,612 KB
testcase_17 AC 281 ms
58,656 KB
testcase_18 AC 281 ms
58,600 KB
testcase_19 AC 286 ms
58,204 KB
testcase_20 AC 140 ms
53,648 KB
testcase_21 AC 141 ms
53,712 KB
testcase_22 AC 136 ms
53,960 KB
testcase_23 AC 142 ms
53,948 KB
testcase_24 AC 165 ms
54,360 KB
testcase_25 AC 191 ms
54,312 KB
testcase_26 AC 139 ms
53,932 KB
testcase_27 AC 134 ms
53,524 KB
testcase_28 AC 141 ms
53,752 KB
testcase_29 AC 228 ms
57,232 KB
testcase_30 AC 219 ms
56,552 KB
testcase_31 AC 134 ms
53,800 KB
testcase_32 AC 137 ms
53,860 KB
testcase_33 AC 135 ms
53,864 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