結果

問題 No.5 数字のブロック
ユーザー k_kadorak_kadora
提出日時 2015-05-18 03:16:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 393 bytes
コンパイル時間 3,323 ms
コンパイル使用メモリ 72,496 KB
実行使用メモリ 60,864 KB
最終ジャッジ日時 2023-09-20 09:44:18
合計ジャッジ時間 10,989 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 124 ms
55,932 KB
testcase_02 AC 123 ms
56,120 KB
testcase_03 AC 230 ms
59,628 KB
testcase_04 AC 207 ms
60,724 KB
testcase_05 AC 249 ms
60,556 KB
testcase_06 AC 224 ms
59,616 KB
testcase_07 AC 221 ms
59,172 KB
testcase_08 AC 224 ms
59,860 KB
testcase_09 AC 200 ms
58,784 KB
testcase_10 AC 247 ms
59,956 KB
testcase_11 AC 217 ms
59,716 KB
testcase_12 AC 239 ms
59,944 KB
testcase_13 AC 247 ms
60,112 KB
testcase_14 AC 138 ms
56,368 KB
testcase_15 AC 148 ms
56,036 KB
testcase_16 AC 245 ms
60,196 KB
testcase_17 AC 258 ms
60,864 KB
testcase_18 AC 254 ms
60,428 KB
testcase_19 AC 257 ms
60,724 KB
testcase_20 AC 126 ms
56,208 KB
testcase_21 AC 126 ms
55,988 KB
testcase_22 AC 125 ms
55,952 KB
testcase_23 AC 124 ms
56,116 KB
testcase_24 AC 151 ms
55,980 KB
testcase_25 AC 177 ms
56,344 KB
testcase_26 AC 125 ms
55,916 KB
testcase_27 AC 129 ms
55,640 KB
testcase_28 AC 123 ms
56,316 KB
testcase_29 AC 216 ms
59,160 KB
testcase_30 AC 200 ms
58,304 KB
testcase_31 AC 125 ms
55,884 KB
testcase_32 AC 123 ms
56,476 KB
testcase_33 AC 123 ms
56,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Count{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		int c = 0;
		int i;
		for(i = 0;i<n;i++){
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		i = 0;
		while((l>=0)&&(i<n)){
			l = l - a[i];
			i++;
			c++;
		}
		if(i!=n)c--;
		System.out.println(c);
	}
}
0