結果

問題 No.5 数字のブロック
ユーザー len_prog
提出日時 2016-06-08 09:34:26
言語 Java
(openjdk 23)
結果
AC  
実行時間 256 ms / 5,000 ms
コード長 520 bytes
コンパイル時間 2,009 ms
コンパイル使用メモリ 74,532 KB
実行使用メモリ 58,732 KB
最終ジャッジ日時 2024-11-18 08:41:21
合計ジャッジ時間 8,715 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int L = scan.nextInt();
		int N = scan.nextInt();
		int[] numbers = new int[N];

		for(int i = 0; i < numbers.length; i++){
			numbers[i] = scan.nextInt();
		}

		Arrays.sort(numbers);
		int total = 0;
		int count = 0;

		for(int i = 0; i < numbers.length; i++){
			total += numbers[i];
			if(total > L) break;

			count++;
		}
		System.out.println(count);
	}

}
0