結果

問題 No.5 数字のブロック
ユーザー youthfuldays072
提出日時 2018-05-20 11:18:16
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 523 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 74,564 KB
実行使用メモリ 47,720 KB
最終ジャッジ日時 2024-06-28 14:34:53
合計ジャッジ時間 9,549 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 7 RE * 7
権限があれば一括ダウンロードができます

ソースコード

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