結果

問題 No.5 数字のブロック
ユーザー youthfuldays072youthfuldays072
提出日時 2018-05-20 11:37:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 280 ms / 5,000 ms
コード長 537 bytes
コンパイル時間 3,700 ms
コンパイル使用メモリ 75,236 KB
実行使用メモリ 47,696 KB
最終ジャッジ日時 2024-04-29 09:51:22
合計ジャッジ時間 11,017 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,356 KB
testcase_01 AC 131 ms
41,228 KB
testcase_02 AC 131 ms
41,172 KB
testcase_03 AC 249 ms
46,788 KB
testcase_04 AC 228 ms
45,696 KB
testcase_05 AC 263 ms
46,860 KB
testcase_06 AC 248 ms
46,456 KB
testcase_07 AC 233 ms
45,860 KB
testcase_08 AC 243 ms
46,436 KB
testcase_09 AC 203 ms
43,356 KB
testcase_10 AC 255 ms
46,916 KB
testcase_11 AC 212 ms
45,504 KB
testcase_12 AC 247 ms
47,156 KB
testcase_13 AC 260 ms
46,536 KB
testcase_14 AC 142 ms
41,372 KB
testcase_15 AC 151 ms
41,560 KB
testcase_16 AC 257 ms
46,804 KB
testcase_17 AC 273 ms
47,504 KB
testcase_18 AC 273 ms
47,540 KB
testcase_19 AC 280 ms
47,696 KB
testcase_20 AC 131 ms
41,124 KB
testcase_21 AC 131 ms
41,436 KB
testcase_22 AC 133 ms
41,292 KB
testcase_23 AC 131 ms
41,340 KB
testcase_24 AC 159 ms
41,888 KB
testcase_25 AC 183 ms
41,920 KB
testcase_26 AC 130 ms
41,224 KB
testcase_27 AC 132 ms
41,136 KB
testcase_28 AC 128 ms
41,000 KB
testcase_29 AC 219 ms
45,640 KB
testcase_30 AC 205 ms
43,944 KB
testcase_31 AC 129 ms
41,028 KB
testcase_32 AC 132 ms
41,040 KB
testcase_33 AC 129 ms
41,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main2 {


    public static void main(String[] args) {

    	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 counter=0;


    	for(int i=0;i<N;i++) {

    		L-=w[i];

    		if(L>=0) {
    			counter++;
    		}else {
    			break;
    		}

    	}

    	System.out.println(counter);

    	sc.close();

    }




}
0