結果

問題 No.5 数字のブロック
ユーザー mits58mits58
提出日時 2016-05-05 14:36:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 252 ms / 5,000 ms
コード長 557 bytes
コンパイル時間 4,052 ms
コンパイル使用メモリ 71,876 KB
実行使用メモリ 61,052 KB
最終ジャッジ日時 2023-08-11 15:01:58
合計ジャッジ時間 11,722 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,516 KB
testcase_01 AC 120 ms
56,116 KB
testcase_02 AC 122 ms
55,948 KB
testcase_03 AC 228 ms
59,540 KB
testcase_04 AC 212 ms
59,432 KB
testcase_05 AC 237 ms
59,800 KB
testcase_06 AC 207 ms
59,784 KB
testcase_07 AC 213 ms
59,372 KB
testcase_08 AC 226 ms
60,224 KB
testcase_09 AC 194 ms
58,492 KB
testcase_10 AC 235 ms
60,152 KB
testcase_11 AC 213 ms
59,584 KB
testcase_12 AC 233 ms
59,516 KB
testcase_13 AC 237 ms
59,832 KB
testcase_14 AC 134 ms
56,144 KB
testcase_15 AC 144 ms
56,052 KB
testcase_16 AC 237 ms
60,392 KB
testcase_17 AC 247 ms
60,104 KB
testcase_18 AC 247 ms
60,056 KB
testcase_19 AC 252 ms
61,052 KB
testcase_20 AC 120 ms
55,512 KB
testcase_21 AC 121 ms
56,132 KB
testcase_22 AC 124 ms
56,240 KB
testcase_23 AC 122 ms
55,824 KB
testcase_24 AC 144 ms
56,540 KB
testcase_25 AC 177 ms
55,988 KB
testcase_26 AC 118 ms
55,820 KB
testcase_27 AC 119 ms
56,056 KB
testcase_28 AC 120 ms
56,020 KB
testcase_29 AC 206 ms
59,704 KB
testcase_30 AC 193 ms
58,432 KB
testcase_31 AC 123 ms
56,240 KB
testcase_32 AC 120 ms
55,724 KB
testcase_33 AC 122 ms
56,112 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