結果

問題 No.5 数字のブロック
ユーザー youthfuldays072youthfuldays072
提出日時 2018-05-20 11:18:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 523 bytes
コンパイル時間 2,353 ms
コンパイル使用メモリ 71,568 KB
実行使用メモリ 61,276 KB
最終ジャッジ日時 2023-09-10 23:55:51
合計ジャッジ時間 9,868 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,816 KB
testcase_01 AC 124 ms
55,760 KB
testcase_02 WA -
testcase_03 AC 238 ms
59,776 KB
testcase_04 AC 220 ms
58,640 KB
testcase_05 WA -
testcase_06 AC 217 ms
61,276 KB
testcase_07 AC 220 ms
59,148 KB
testcase_08 AC 223 ms
60,456 KB
testcase_09 AC 197 ms
58,012 KB
testcase_10 AC 247 ms
59,916 KB
testcase_11 AC 218 ms
59,208 KB
testcase_12 AC 244 ms
60,156 KB
testcase_13 AC 247 ms
59,548 KB
testcase_14 AC 140 ms
56,000 KB
testcase_15 WA -
testcase_16 AC 246 ms
59,804 KB
testcase_17 AC 254 ms
58,176 KB
testcase_18 AC 252 ms
59,940 KB
testcase_19 AC 254 ms
60,556 KB
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 123 ms
55,540 KB
testcase_24 AC 152 ms
56,112 KB
testcase_25 AC 178 ms
55,988 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 WA -
testcase_30 WA -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main {


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

    	while(true) {

    		L-=w[index];

    		if(L<=0) {
    			break;
    		}else {
    			index++;
    		}
    	}

    	System.out.println(index);

    	sc.close();

    }




}
0