結果

問題 No.5 数字のブロック
ユーザー SuunnSuunn
提出日時 2018-11-20 04:45:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 283 ms / 5,000 ms
コード長 440 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 74,716 KB
実行使用メモリ 47,736 KB
最終ジャッジ日時 2024-04-29 10:06:10
合計ジャッジ時間 10,598 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,076 KB
testcase_01 AC 136 ms
41,400 KB
testcase_02 AC 136 ms
41,436 KB
testcase_03 AC 252 ms
46,052 KB
testcase_04 AC 232 ms
45,420 KB
testcase_05 AC 258 ms
46,396 KB
testcase_06 AC 246 ms
46,120 KB
testcase_07 AC 236 ms
45,384 KB
testcase_08 AC 256 ms
46,352 KB
testcase_09 AC 223 ms
43,212 KB
testcase_10 AC 275 ms
46,688 KB
testcase_11 AC 246 ms
45,892 KB
testcase_12 AC 264 ms
46,328 KB
testcase_13 AC 256 ms
46,396 KB
testcase_14 AC 145 ms
41,224 KB
testcase_15 AC 155 ms
41,556 KB
testcase_16 AC 269 ms
46,664 KB
testcase_17 AC 283 ms
47,736 KB
testcase_18 AC 274 ms
46,236 KB
testcase_19 AC 280 ms
47,512 KB
testcase_20 AC 135 ms
41,184 KB
testcase_21 AC 132 ms
41,528 KB
testcase_22 AC 129 ms
41,036 KB
testcase_23 AC 118 ms
40,204 KB
testcase_24 AC 166 ms
41,772 KB
testcase_25 AC 184 ms
41,740 KB
testcase_26 AC 132 ms
41,284 KB
testcase_27 AC 134 ms
41,184 KB
testcase_28 AC 131 ms
41,188 KB
testcase_29 AC 226 ms
45,768 KB
testcase_30 AC 211 ms
43,748 KB
testcase_31 AC 120 ms
40,308 KB
testcase_32 AC 138 ms
41,480 KB
testcase_33 AC 133 ms
41,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main{
	
	
	public static void main(String args[])throws Exception{
		
		Scanner sc = new Scanner(System.in);
	
		int L = sc.nextInt();
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0;i<N;i++){
			W[i] = sc.nextInt();
		}
		Arrays.sort(W);
		int ans = 0;
		for(int i=0;i<N;i++){
			L -= W[i];
			if(L>=0){
				ans++;
			}
		}
		System.out.println(ans);
	}
	
}
0