結果

問題 No.5 数字のブロック
ユーザー HEGO55HEGO55
提出日時 2017-05-09 21:39:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 268 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 2,055 ms
コンパイル使用メモリ 74,268 KB
実行使用メモリ 47,436 KB
最終ジャッジ日時 2024-04-29 08:58:23
合計ジャッジ時間 9,302 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
40,904 KB
testcase_01 AC 113 ms
40,072 KB
testcase_02 AC 114 ms
40,140 KB
testcase_03 AC 241 ms
46,276 KB
testcase_04 AC 225 ms
45,960 KB
testcase_05 AC 248 ms
47,056 KB
testcase_06 AC 229 ms
45,872 KB
testcase_07 AC 223 ms
45,840 KB
testcase_08 AC 235 ms
46,424 KB
testcase_09 AC 199 ms
43,416 KB
testcase_10 AC 250 ms
46,796 KB
testcase_11 AC 217 ms
45,776 KB
testcase_12 AC 240 ms
46,740 KB
testcase_13 AC 258 ms
46,456 KB
testcase_14 AC 139 ms
41,528 KB
testcase_15 AC 151 ms
41,600 KB
testcase_16 AC 268 ms
46,384 KB
testcase_17 AC 261 ms
47,260 KB
testcase_18 AC 263 ms
46,780 KB
testcase_19 AC 268 ms
47,436 KB
testcase_20 AC 114 ms
39,992 KB
testcase_21 AC 123 ms
40,992 KB
testcase_22 AC 132 ms
41,200 KB
testcase_23 AC 114 ms
40,280 KB
testcase_24 AC 159 ms
41,468 KB
testcase_25 AC 175 ms
41,764 KB
testcase_26 AC 130 ms
40,932 KB
testcase_27 AC 125 ms
40,828 KB
testcase_28 AC 127 ms
41,084 KB
testcase_29 AC 219 ms
45,824 KB
testcase_30 AC 199 ms
43,552 KB
testcase_31 AC 114 ms
40,284 KB
testcase_32 AC 121 ms
40,360 KB
testcase_33 AC 117 ms
40,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class Test27{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); //16
		int W = sc.nextInt(); //3
		int[] num = new int[W]; //0,1,2
		int count = 0;
		
		for(int i=0; i<W; i++){ //i=0,1,2
			num[i] = sc.nextInt(); //num[0]=10 num[1]=5 num[2]=7
		}
		
	    Arrays.sort(num);
				
		for(int m=0; m<num.length; m++){
			N -= num[m];
			if(N>=0){
				count++;
			}
		}
		
		System.out.println(count);
	}
}
0