結果

問題 No.5 数字のブロック
ユーザー mits58mits58
提出日時 2016-05-05 14:36:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 285 ms / 5,000 ms
コード長 557 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 74,480 KB
実行使用メモリ 47,748 KB
最終ジャッジ日時 2024-04-29 07:13:38
合計ジャッジ時間 9,667 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,264 KB
testcase_01 AC 115 ms
39,952 KB
testcase_02 AC 128 ms
41,236 KB
testcase_03 AC 241 ms
46,384 KB
testcase_04 AC 221 ms
45,700 KB
testcase_05 AC 258 ms
46,404 KB
testcase_06 AC 238 ms
46,408 KB
testcase_07 AC 229 ms
45,884 KB
testcase_08 AC 244 ms
46,496 KB
testcase_09 AC 201 ms
43,408 KB
testcase_10 AC 263 ms
47,256 KB
testcase_11 AC 228 ms
45,364 KB
testcase_12 AC 249 ms
46,924 KB
testcase_13 AC 260 ms
47,084 KB
testcase_14 AC 144 ms
41,792 KB
testcase_15 AC 159 ms
41,412 KB
testcase_16 AC 258 ms
46,900 KB
testcase_17 AC 268 ms
47,748 KB
testcase_18 AC 275 ms
47,468 KB
testcase_19 AC 285 ms
47,392 KB
testcase_20 AC 132 ms
41,152 KB
testcase_21 AC 136 ms
41,268 KB
testcase_22 AC 134 ms
41,328 KB
testcase_23 AC 128 ms
41,048 KB
testcase_24 AC 154 ms
41,464 KB
testcase_25 AC 173 ms
41,776 KB
testcase_26 AC 114 ms
40,204 KB
testcase_27 AC 115 ms
40,056 KB
testcase_28 AC 116 ms
40,148 KB
testcase_29 AC 223 ms
45,516 KB
testcase_30 AC 201 ms
44,084 KB
testcase_31 AC 129 ms
41,016 KB
testcase_32 AC 127 ms
41,020 KB
testcase_33 AC 121 ms
40,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main{
	public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
        	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 res=0;
        	int sum=0;
        	for(int i=0;i<n;i++){
        		if(sum+w[i]<=l){
        			sum+=w[i];
        			res++;
        		}
        	}
        	System.out.println(res);
        }
    }
}
0