結果

問題 No.5 数字のブロック
ユーザー 8130Tsk
提出日時 2015-07-26 22:21:15
言語 Java
(openjdk 23)
結果
AC  
実行時間 247 ms / 5,000 ms
コード長 542 bytes
コンパイル時間 3,314 ms
コンパイル使用メモリ 74,832 KB
実行使用メモリ 59,080 KB
最終ジャッジ日時 2024-11-18 07:28:52
合計ジャッジ時間 10,143 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No5 {

	public void run(){
		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 sum = 0;
		int count = 0;
		for(int i=0; i<N ;i++){
			sum+=w[i];
			if(sum>L)
				break;
			count++;
		}
		
		System.out.println(count);
		
		
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new No5().run();
	}

}
0