結果

問題 No.5 数字のブロック
ユーザー mits58
提出日時 2015-07-18 01:06:43
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 639 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 74,852 KB
実行使用メモリ 48,036 KB
最終ジャッジ日時 2024-07-08 10:00:56
合計ジャッジ時間 8,982 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

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 result=0;
        	int[] box=new int[n];
        	
        	for(int i=0;i<n;i++){
        		box[i]=sc.nextInt();
        	}
        	
        	Arrays.sort(box);
        	
        	for(int i=0;i<n;i++){
        		result+=box[i];
        		if(result<=l) continue;
        		else{
        			System.out.println(i);
        			break;
        		}
        	}
        	
        }
    }
}
0