結果

問題 No.5 数字のブロック
ユーザー Koketti1
提出日時 2017-02-04 14:28:23
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 2,013 ms
コンパイル使用メモリ 73,968 KB
実行使用メモリ 47,716 KB
最終ジャッジ日時 2024-12-24 06:14:52
合計ジャッジ時間 9,161 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 7 RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int sum = 0;
		int count = 0;
		int L = scanner.nextInt();
		int N = scanner.nextInt();
		int a[] = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = scanner.nextInt();
		}
		Arrays.sort(a);
		while(sum<L){
			sum += a[count];
			count++;
		}
		
		System.out.println(count-1);
		
		scanner.close();
	}
}
0