結果

問題 No.5 数字のブロック
ユーザー Mcpu3
提出日時 2018-09-05 16:55:55
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 411 bytes
コンパイル時間 2,443 ms
コンパイル使用メモリ 74,396 KB
実行使用メモリ 47,864 KB
最終ジャッジ日時 2024-11-15 17:18:00
合計ジャッジ時間 9,907 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int l=sc.nextInt(),n=sc.nextInt(),w[]=new int[n],s=0,t=0,i;
		for(i=0;i<n;++i) {
			w[i]=sc.nextInt();
			s+=w[i];
		}
		sc.close();
		Arrays.sort(w);
		for(i=0;;++i) {
			t+=w[i];
			if(t>l) break;
		}
		if(l>=s) i=n;
		System.out.print(i);
	}
}
0