結果

問題 No.5 数字のブロック
ユーザー Mcpu3
提出日時 2018-09-05 16:58:32
言語 Java
(openjdk 23)
結果
AC  
実行時間 249 ms / 5,000 ms
コード長 397 bytes
コンパイル時間 1,874 ms
コンパイル使用メモリ 74,308 KB
実行使用メモリ 59,292 KB
最終ジャッジ日時 2024-11-18 12:36:03
合計ジャッジ時間 8,542 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

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<n;++i) {
			t+=w[i];
			if(t>l) break;
		}
		System.out.print(i);
	}
}
0