結果

問題 No.5 数字のブロック
ユーザー shinwisteria
提出日時 2017-03-18 20:02:35
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 407 bytes
コンパイル時間 3,138 ms
コンパイル使用メモリ 75,248 KB
実行使用メモリ 54,340 KB
最終ジャッジ日時 2024-07-04 19:21:02
合計ジャッジ時間 10,461 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class NumberBlock {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int L = s.nextInt(), N = s.nextInt(), sum = 0;
		
		int[] W = new int[N];
		for(int i = 0;i<N;i++){
			W[i] = s.nextInt();
		}
		s.close();
		Arrays.sort(W);
		int t=0;
		do{
			sum += W[t++];
		}while(sum <= L);
		System.out.println(t-1);
	}

}
0