結果

問題 No.5 数字のブロック
ユーザー DemocoDemoco
提出日時 2015-05-01 18:08:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 427 bytes
コンパイル時間 2,125 ms
コンパイル使用メモリ 71,700 KB
実行使用メモリ 60,820 KB
最終ジャッジ日時 2023-09-19 04:54:35
合計ジャッジ時間 9,934 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 125 ms
55,528 KB
testcase_02 RE -
testcase_03 AC 239 ms
59,532 KB
testcase_04 AC 209 ms
58,752 KB
testcase_05 AC 247 ms
60,332 KB
testcase_06 AC 226 ms
59,632 KB
testcase_07 AC 221 ms
59,660 KB
testcase_08 AC 229 ms
59,896 KB
testcase_09 AC 197 ms
58,708 KB
testcase_10 AC 249 ms
60,100 KB
testcase_11 AC 218 ms
59,736 KB
testcase_12 AC 237 ms
60,200 KB
testcase_13 AC 244 ms
59,536 KB
testcase_14 AC 139 ms
55,896 KB
testcase_15 AC 153 ms
56,092 KB
testcase_16 AC 245 ms
59,840 KB
testcase_17 AC 251 ms
60,616 KB
testcase_18 AC 258 ms
60,440 KB
testcase_19 AC 259 ms
60,820 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 125 ms
56,224 KB
testcase_24 AC 149 ms
55,740 KB
testcase_25 AC 181 ms
55,932 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 218 ms
58,972 KB
testcase_30 AC 200 ms
58,652 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class Yukico5 {
	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 a=0;
		int i=0;
		while(a<=l) {
			a = a+w[i];
			i++;
		}
		if(i==n) {
			System.out.println(i);
		} else {
			System.out.println(i-1);
		}
	}
}
0