結果

問題 No.5 数字のブロック
ユーザー yuma_shobon1108yuma_shobon1108
提出日時 2016-11-04 15:28:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 278 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 73,992 KB
実行使用メモリ 47,552 KB
最終ジャッジ日時 2024-04-29 08:36:20
合計ジャッジ時間 9,893 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,564 KB
testcase_01 AC 136 ms
41,468 KB
testcase_02 AC 137 ms
41,164 KB
testcase_03 AC 251 ms
46,252 KB
testcase_04 AC 227 ms
45,520 KB
testcase_05 AC 263 ms
46,964 KB
testcase_06 AC 238 ms
46,012 KB
testcase_07 AC 229 ms
46,080 KB
testcase_08 AC 248 ms
46,780 KB
testcase_09 AC 203 ms
43,692 KB
testcase_10 AC 259 ms
47,284 KB
testcase_11 AC 225 ms
45,792 KB
testcase_12 AC 252 ms
47,064 KB
testcase_13 AC 255 ms
46,584 KB
testcase_14 AC 143 ms
41,484 KB
testcase_15 AC 154 ms
41,276 KB
testcase_16 AC 264 ms
46,764 KB
testcase_17 AC 272 ms
47,528 KB
testcase_18 AC 266 ms
46,788 KB
testcase_19 AC 278 ms
47,552 KB
testcase_20 AC 132 ms
41,012 KB
testcase_21 AC 132 ms
41,140 KB
testcase_22 AC 118 ms
40,184 KB
testcase_23 AC 129 ms
41,360 KB
testcase_24 AC 169 ms
41,532 KB
testcase_25 AC 182 ms
42,080 KB
testcase_26 AC 133 ms
41,344 KB
testcase_27 AC 132 ms
41,388 KB
testcase_28 AC 130 ms
40,996 KB
testcase_29 AC 226 ms
46,000 KB
testcase_30 AC 205 ms
43,636 KB
testcase_31 AC 134 ms
41,124 KB
testcase_32 AC 130 ms
41,080 KB
testcase_33 AC 131 ms
41,080 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