結果

問題 No.5 数字のブロック
ユーザー k_kadorak_kadora
提出日時 2015-05-18 03:20:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 279 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 3,836 ms
コンパイル使用メモリ 74,496 KB
実行使用メモリ 58,744 KB
最終ジャッジ日時 2024-04-29 00:55:27
合計ジャッジ時間 11,452 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
53,784 KB
testcase_01 AC 142 ms
53,976 KB
testcase_02 AC 136 ms
53,884 KB
testcase_03 AC 251 ms
58,072 KB
testcase_04 AC 225 ms
57,120 KB
testcase_05 AC 256 ms
57,700 KB
testcase_06 AC 246 ms
57,632 KB
testcase_07 AC 235 ms
56,892 KB
testcase_08 AC 241 ms
56,996 KB
testcase_09 AC 207 ms
56,200 KB
testcase_10 AC 265 ms
58,444 KB
testcase_11 AC 229 ms
57,352 KB
testcase_12 AC 254 ms
57,572 KB
testcase_13 AC 263 ms
57,732 KB
testcase_14 AC 147 ms
53,848 KB
testcase_15 AC 159 ms
54,200 KB
testcase_16 AC 265 ms
58,364 KB
testcase_17 AC 274 ms
58,252 KB
testcase_18 AC 274 ms
58,116 KB
testcase_19 AC 279 ms
58,744 KB
testcase_20 AC 135 ms
53,972 KB
testcase_21 AC 136 ms
53,608 KB
testcase_22 AC 133 ms
53,560 KB
testcase_23 AC 135 ms
53,968 KB
testcase_24 AC 176 ms
54,180 KB
testcase_25 AC 207 ms
54,668 KB
testcase_26 AC 141 ms
53,828 KB
testcase_27 AC 135 ms
53,672 KB
testcase_28 AC 136 ms
54,164 KB
testcase_29 AC 228 ms
56,976 KB
testcase_30 AC 209 ms
56,556 KB
testcase_31 AC 139 ms
53,900 KB
testcase_32 AC 132 ms
53,600 KB
testcase_33 AC 137 ms
53,936 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)||(l<0))c--;
		System.out.println(c);
	}
}
0