結果

問題 No.5 数字のブロック
ユーザー k_kadorak_kadora
提出日時 2015-05-18 03:20:14
言語 Java19
(openjdk 21)
結果
AC  
実行時間 254 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 4,200 ms
コンパイル使用メモリ 71,512 KB
実行使用メモリ 60,476 KB
最終ジャッジ日時 2023-08-11 08:21:40
合計ジャッジ時間 10,751 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,740 KB
testcase_01 AC 124 ms
55,828 KB
testcase_02 AC 122 ms
55,800 KB
testcase_03 AC 225 ms
59,376 KB
testcase_04 AC 210 ms
59,136 KB
testcase_05 AC 244 ms
60,476 KB
testcase_06 AC 223 ms
59,272 KB
testcase_07 AC 215 ms
59,008 KB
testcase_08 AC 228 ms
59,976 KB
testcase_09 AC 194 ms
59,244 KB
testcase_10 AC 241 ms
58,136 KB
testcase_11 AC 214 ms
59,268 KB
testcase_12 AC 234 ms
59,764 KB
testcase_13 AC 241 ms
59,908 KB
testcase_14 AC 139 ms
55,756 KB
testcase_15 AC 160 ms
57,772 KB
testcase_16 AC 249 ms
60,244 KB
testcase_17 AC 254 ms
60,132 KB
testcase_18 AC 252 ms
60,388 KB
testcase_19 AC 252 ms
60,296 KB
testcase_20 AC 123 ms
55,876 KB
testcase_21 AC 122 ms
53,772 KB
testcase_22 AC 123 ms
55,824 KB
testcase_23 AC 124 ms
55,864 KB
testcase_24 AC 150 ms
55,896 KB
testcase_25 AC 180 ms
55,888 KB
testcase_26 AC 126 ms
55,476 KB
testcase_27 AC 126 ms
55,916 KB
testcase_28 AC 127 ms
55,808 KB
testcase_29 AC 209 ms
59,448 KB
testcase_30 AC 201 ms
58,444 KB
testcase_31 AC 125 ms
55,860 KB
testcase_32 AC 125 ms
55,740 KB
testcase_33 AC 123 ms
55,748 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