結果

問題 No.5 数字のブロック
ユーザー yuma_shobon1108yuma_shobon1108
提出日時 2016-11-04 15:25:43
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 1,907 ms
コンパイル使用メモリ 74,224 KB
実行使用メモリ 59,908 KB
最終ジャッジ日時 2024-11-25 02:56:37
合計ジャッジ時間 8,692 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Question005
{
	public static void main(String[] str)
	{
	
		Scanner scan = new Scanner(System.in);
		
		int width = scan.nextInt();
		int num = scan.nextInt();
		int block[] = new int[num];
		
		for(int i=0; i<num; i++){
			block[i] = scan.nextInt();

		}
		
		Arrays.sort(block);
		
		int cnt=0;
		
		for(int i=0; i<num; i++){
			width = width - block[i];
			if(width <= 0){
				cnt++;
				continue;
			}
			cnt++;
		}
		
		System.out.println(cnt);
	}
}
0