結果

問題 No.5 数字のブロック
ユーザー yuma_shobon1108yuma_shobon1108
提出日時 2016-11-04 15:28:44
言語 Java19
(openjdk 21)
結果
AC  
実行時間 253 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 2,084 ms
コンパイル使用メモリ 72,088 KB
実行使用メモリ 61,080 KB
最終ジャッジ日時 2023-08-11 16:47:49
合計ジャッジ時間 9,915 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,600 KB
testcase_01 AC 125 ms
56,140 KB
testcase_02 AC 123 ms
55,940 KB
testcase_03 AC 229 ms
60,020 KB
testcase_04 AC 208 ms
59,200 KB
testcase_05 AC 243 ms
59,916 KB
testcase_06 AC 213 ms
60,008 KB
testcase_07 AC 211 ms
59,496 KB
testcase_08 AC 222 ms
59,836 KB
testcase_09 AC 202 ms
58,416 KB
testcase_10 AC 242 ms
59,912 KB
testcase_11 AC 213 ms
59,380 KB
testcase_12 AC 233 ms
59,820 KB
testcase_13 AC 241 ms
60,248 KB
testcase_14 AC 139 ms
56,124 KB
testcase_15 AC 157 ms
55,800 KB
testcase_16 AC 240 ms
60,228 KB
testcase_17 AC 253 ms
60,712 KB
testcase_18 AC 253 ms
61,080 KB
testcase_19 AC 253 ms
60,652 KB
testcase_20 AC 124 ms
56,080 KB
testcase_21 AC 125 ms
58,276 KB
testcase_22 AC 123 ms
55,860 KB
testcase_23 AC 123 ms
55,984 KB
testcase_24 AC 151 ms
55,920 KB
testcase_25 AC 177 ms
56,628 KB
testcase_26 AC 124 ms
56,092 KB
testcase_27 AC 123 ms
55,804 KB
testcase_28 AC 123 ms
56,024 KB
testcase_29 AC 215 ms
58,796 KB
testcase_30 AC 196 ms
58,360 KB
testcase_31 AC 125 ms
55,752 KB
testcase_32 AC 125 ms
56,136 KB
testcase_33 AC 123 ms
55,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

class Question005
{
	public static void main(String[] str)
	{
	
		Scanner scan = new Scanner(System.in);
		
		int width = scan.nextInt();
		int num = scan.nextInt();
		int block[] = new int[num];
		
		for(int i=0; i<num; i++){
			block[i] = scan.nextInt();

		}
		
		Arrays.sort(block);
		
		int cnt=0;
		
		for(int i=0; i<num; i++){
			width = width - block[i];
			if(width < 0){
				continue;
			}
			cnt++;
		}
		
		System.out.println(cnt);
	}
}
0